(\s+)<\/span>/g,((e,t)=>1==t.length?" ":t)).replace(//g,"")}(r.getData("text/html")):r.getData("text/plain")&&(((o=(o=r.getData("text/plain")).replace(//g,">").replace(/\r?\n\r?\n/g,"").replace(/\r?\n/g,"
").replace(/\t/g," ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("
")||o.includes("
"))&&(o=`
${o}
`),e=o),i=this.editor.data.htmlProcessor.toView(e)}var o;const s=new g(this,"inputTransformation");this.fire(s,{content:i,dataTransfer:r,targetRanges:t.targetRanges,method:t.method}),s.stop.called&&e.stop(),n.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((e,n)=>{if(n.content.isEmpty)return;const r=this.editor.data.toModel(n.content,"$clipboardHolder");0!=r.childCount&&(e.stop(),t.change((()=>{this.fire("contentInsertion",{content:r,method:n.method,dataTransfer:n.dataTransfer,targetRanges:n.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((e,n)=>{n.resultRange=t.insertContent(n.content)}),{priority:"low"})}_setupCopyCut(){const e=this.editor,t=e.model.document,n=e.editing.view.document,r=(r,i)=>{const o=i.dataTransfer;i.preventDefault();const s=e.data.toView(e.model.getSelectedContent(t.selection));n.fire("clipboardOutput",{dataTransfer:o,content:s,method:r.name})};this.listenTo(n,"copy",r,{priority:"low"}),this.listenTo(n,"cut",((t,n)=>{e.model.canEditAt(e.model.document.selection)?r(t,n):n.preventDefault()}),{priority:"low"}),this.listenTo(n,"clipboardOutput",((n,r)=>{r.content.isEmpty||(r.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(r.content)),r.dataTransfer.setData("text/plain",gf(r.content))),"cut"==r.method&&e.model.deleteContent(t.selection)}),{priority:"low"})}}class yf{constructor(e,t=20){this._batch=null,this.model=e,this._size=0,this.limit=t,this._isLocked=!1,this._changeCallback=(e,t)=>{t.isLocal&&t.isUndoable&&t!==this._batch&&this._reset(!0)},this._selectionChangeCallback=()=>{this._reset()},this.model.document.on("change",this._changeCallback),this.model.document.selection.on("change:range",this._selectionChangeCallback),this.model.document.selection.on("change:attribute",this._selectionChangeCallback)}get batch(){return this._batch||(this._batch=this.model.createBatch({isTyping:!0})),this._batch}get size(){return this._size}input(e){this._size+=e,this._size>=this.limit&&this._reset(!0)}get isLocked(){return this._isLocked}lock(){this._isLocked=!0}unlock(){this._isLocked=!1}destroy(){this.model.document.off("change",this._changeCallback),this.model.document.selection.off("change:range",this._selectionChangeCallback),this.model.document.selection.off("change:attribute",this._selectionChangeCallback)}_reset(e=!1){this.isLocked&&!e||(this._batch=null,this._size=0)}}class vf extends Gi{constructor(e,t){super(e),this._buffer=new yf(e.model,t),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}destroy(){super.destroy(),this._buffer.destroy()}execute(e={}){const t=this.editor.model,n=t.document,r=e.text||"",i=r.length;let o=n.selection;if(e.selection?o=e.selection:e.range&&(o=t.createSelection(e.range)),!t.canEditAt(o))return;const s=e.resultRange;t.enqueueChange(this._buffer.batch,(e=>{this._buffer.lock(),t.deleteContent(o),r&&t.insertContent(e.createText(r,n.selection.getAttributes()),o),s?e.setSelection(s):o.is("documentSelection")||e.setSelection(o),this._buffer.unlock(),this._buffer.input(i)}))}}const _f=["insertText","insertReplacementText"];class wf extends fa{constructor(e){super(e),u.isAndroid&&_f.push("insertCompositionText");const t=e.document;t.on("beforeinput",((n,r)=>{if(!this.isEnabled)return;const{data:i,targetRanges:o,inputType:s,domEvent:a}=r;if(!_f.includes(s))return;const l=new g(t,"insertText");t.fire(l,new ga(e,a,{text:i,selection:e.createSelection(o)})),l.stop.called&&n.stop()})),t.on("compositionend",((n,{data:r,domEvent:i})=>{this.isEnabled&&!u.isAndroid&&r&&t.fire("insertText",new ga(e,i,{text:r,selection:t.selection}))}),{priority:"lowest"})}observe(){}stopObserving(){}}class kf extends qi{static get pluginName(){return"Input"}init(){const e=this.editor,t=e.model,n=e.editing.view,r=t.document.selection;n.addObserver(wf);const i=new vf(e,e.config.get("typing.undoStep")||20);e.commands.add("insertText",i),e.commands.add("input",i),this.listenTo(n.document,"insertText",((r,i)=>{n.document.isComposing||i.preventDefault();const{text:o,selection:s,resultRange:a}=i,l=Array.from(s.getRanges()).map((t=>e.editing.mapper.toModelRange(t)));let c=o;if(u.isAndroid){const e=Array.from(l[0].getItems()).reduce(((e,t)=>e+(t.is("$textProxy")?t.data:"")),"");e&&(e.length<=c.length?c.startsWith(e)&&(c=c.substring(e.length),l[0].start=l[0].start.getShiftedBy(e.length)):e.startsWith(c)&&(l[0].start=l[0].start.getShiftedBy(c.length),c=""))}const d={text:c,selection:t.createSelection(l)};a&&(d.resultRange=e.editing.mapper.toModelRange(a)),e.execute("insertText",d)})),u.isAndroid?this.listenTo(n.document,"keydown",((e,o)=>{!r.isCollapsed&&229==o.keyCode&&n.document.isComposing&&xf(t,i)})):this.listenTo(n.document,"compositionstart",(()=>{r.isCollapsed||xf(t,i)}))}}function xf(e,t){if(!t.isEnabled)return;const n=t.buffer;n.lock(),e.enqueueChange(n.batch,(()=>{e.deleteContent(e.document.selection)})),n.unlock()}class Cf extends Gi{constructor(e,t){super(e),this.direction=t,this._buffer=new yf(e.model,e.config.get("typing.undoStep")),this._isEnabledBasedOnSelection=!1}get buffer(){return this._buffer}execute(e={}){const t=this.editor.model,n=t.document;t.enqueueChange(this._buffer.batch,(r=>{this._buffer.lock();const i=r.createSelection(e.selection||n.selection);if(!t.canEditAt(i))return;const o=e.sequence||1,s=i.isCollapsed;if(i.isCollapsed&&t.modifySelection(i,{direction:this.direction,unit:e.unit,treatEmojiAsSingleUnit:!0}),this._shouldEntireContentBeReplacedWithParagraph(o))return void this._replaceEntireContentWithParagraph(r);if(this._shouldReplaceFirstBlockWithParagraph(i,o))return void this.editor.execute("paragraph",{selection:i});if(i.isCollapsed)return;let a=0;i.getFirstRange().getMinimalFlatRanges().forEach((e=>{a+=te(e.getWalker({singleCharacters:!0,ignoreElementEnd:!0,shallow:!0}))})),t.deleteContent(i,{doNotResetEntireContent:s,direction:this.direction}),this._buffer.input(a),r.setSelection(i),this._buffer.unlock()}))}_shouldEntireContentBeReplacedWithParagraph(e){if(e>1)return!1;const t=this.editor.model,n=t.document.selection,r=t.schema.getLimitElement(n);if(!n.isCollapsed||!n.containsEntireContent(r))return!1;if(!t.schema.checkChild(r,"paragraph"))return!1;const i=r.getChild(0);return!i||!i.is("element","paragraph")}_replaceEntireContentWithParagraph(e){const t=this.editor.model,n=t.document.selection,r=t.schema.getLimitElement(n),i=e.createElement("paragraph");e.remove(e.createRangeIn(r)),e.insert(i,r),e.setSelection(i,0)}_shouldReplaceFirstBlockWithParagraph(e,t){const n=this.editor.model;if(t>1||"backward"!=this.direction)return!1;if(!e.isCollapsed)return!1;const r=e.getFirstPosition(),i=n.schema.getLimitElement(r),o=i.getChild(0);return r.parent==o&&!!e.containsEntireContent(o)&&!!n.schema.checkChild(i,"paragraph")&&"paragraph"!=o.name}}const jf="word",Af="selection",Sf="backward",Mf="forward",Nf={deleteContent:{unit:Af,direction:Sf},deleteContentBackward:{unit:"codePoint",direction:Sf},deleteWordBackward:{unit:jf,direction:Sf},deleteHardLineBackward:{unit:Af,direction:Sf},deleteSoftLineBackward:{unit:Af,direction:Sf},deleteContentForward:{unit:"character",direction:Mf},deleteWordForward:{unit:jf,direction:Mf},deleteHardLineForward:{unit:Af,direction:Mf},deleteSoftLineForward:{unit:Af,direction:Mf}};class Ef extends fa{constructor(e){super(e);const t=e.document;let n=0;t.on("keydown",(()=>{n++})),t.on("keyup",(()=>{n=0})),t.on("beforeinput",((r,i)=>{if(!this.isEnabled)return;const{targetRanges:o,domEvent:s,inputType:a}=i,l=Nf[a];if(!l)return;const c={direction:l.direction,unit:l.unit,sequence:n};c.unit==Af&&(c.selectionToRemove=e.createSelection(o[0])),"deleteContentBackward"===a&&(u.isAndroid&&(c.sequence=1),function(e){if(1!=e.length||e[0].isCollapsed)return!1;const t=e[0].getWalker({direction:"backward",singleCharacters:!0,ignoreElementEnd:!0});let n=0;for(const{nextPosition:e}of t){if(e.parent.is("$text")){const t=e.parent.data,r=e.offset;if(Ur(t,r)||Wr(t,r)||qr(t,r))continue;n++}else n++;if(n>1)return!0}return!1}(o)&&(c.unit=Af,c.selectionToRemove=e.createSelection(o)));const d=new fs(t,"delete",o[0]);t.fire(d,new ga(e,s,c)),d.stop.called&&r.stop()})),u.isBlink&&function(e){const t=e.view,n=t.document;let r=null,i=!1;function o(e){return e==Mr.backspace||e==Mr.delete}function s(e){return e==Mr.backspace?Sf:Mf}n.on("keydown",((e,{keyCode:t})=>{r=t,i=!1})),n.on("keyup",((a,{keyCode:l,domEvent:c})=>{const u=n.selection,d=e.isEnabled&&l==r&&o(l)&&!u.isCollapsed&&!i;if(r=null,d){const e=u.getFirstRange(),r=new fs(n,"delete",e),i={unit:Af,direction:s(l),selectionToRemove:u};n.fire(r,new ga(t,c,i))}})),n.on("beforeinput",((e,{inputType:t})=>{const n=Nf[t];o(r)&&n&&n.direction==s(r)&&(i=!0)}),{priority:"high"}),n.on("beforeinput",((e,{inputType:t,data:n})=>{r==Mr.delete&&"insertText"==t&&""==n&&e.stop()}),{priority:"high"})}(this)}observe(){}stopObserving(){}}class Df extends qi{static get pluginName(){return"Delete"}init(){const e=this.editor,t=e.editing.view,n=t.document,r=e.model.document;t.addObserver(Ef),this._undoOnBackspace=!1;const i=new Cf(e,"forward");e.commands.add("deleteForward",i),e.commands.add("forwardDelete",i),e.commands.add("delete",new Cf(e,"backward")),this.listenTo(n,"delete",((r,i)=>{n.isComposing||i.preventDefault();const{direction:o,sequence:s,selectionToRemove:a,unit:l}=i,c="forward"===o?"deleteForward":"delete",u={sequence:s};if("selection"==l){const t=Array.from(a.getRanges()).map((t=>e.editing.mapper.toModelRange(t)));u.selection=e.model.createSelection(t)}else u.unit=l;e.execute(c,u),t.scrollToTheSelection()}),{priority:"low"}),this.editor.plugins.has("UndoEditing")&&(this.listenTo(n,"delete",((t,n)=>{this._undoOnBackspace&&"backward"==n.direction&&1==n.sequence&&"codePoint"==n.unit&&(this._undoOnBackspace=!1,e.execute("undo"),n.preventDefault(),t.stop())}),{context:"$capture"}),this.listenTo(r,"change",(()=>{this._undoOnBackspace=!1})))}requestUndoOnBackspace(){this.editor.plugins.has("UndoEditing")&&(this._undoOnBackspace=!0)}}class Tf extends qi{static get requires(){return[kf,Df]}static get pluginName(){return"Typing"}}function Of(e,t){let n=e.start;return{text:Array.from(e.getWalker({ignoreElementEnd:!1})).reduce(((e,{item:r})=>r.is("$text")||r.is("$textProxy")?e+r.data:(n=t.createPositionAfter(r),"")),""),range:t.createRange(n,e.end)}}class Lf extends(Z()){constructor(e,t){super(),this.model=e,this.testCallback=t,this._hasMatch=!1,this.set("isEnabled",!0),this.on("change:isEnabled",(()=>{this.isEnabled?this._startListening():(this.stopListening(e.document.selection),this.stopListening(e.document))})),this._startListening()}get hasMatch(){return this._hasMatch}_startListening(){const e=this.model.document;this.listenTo(e.selection,"change:range",((t,{directChange:n})=>{n&&(e.selection.isCollapsed?this._evaluateTextBeforeSelection("selection"):this.hasMatch&&(this.fire("unmatched"),this._hasMatch=!1))})),this.listenTo(e,"change:data",((e,t)=>{!t.isUndo&&t.isLocal&&this._evaluateTextBeforeSelection("data",{batch:t})}))}_evaluateTextBeforeSelection(e,t={}){const n=this.model,r=n.document.selection,i=n.createRange(n.createPositionAt(r.focus.parent,0),r.focus),{text:o,range:s}=Of(i,n),a=this.testCallback(o);if(!a&&this.hasMatch&&this.fire("unmatched"),this._hasMatch=!!a,a){const n=Object.assign(t,{text:o,range:s});"object"==typeof a&&Object.assign(n,a),this.fire(`matched:${e}`,n)}}}class Pf extends qi{constructor(e){super(e),this.attributes=new Set,this._overrideUid=null}static get pluginName(){return"TwoStepCaretMovement"}init(){const e=this.editor,t=e.model,n=e.editing.view,r=e.locale,i=t.document.selection;this.listenTo(n.document,"arrowKey",((e,t)=>{if(!i.isCollapsed)return;if(t.shiftKey||t.altKey||t.ctrlKey)return;const n=t.keyCode==Mr.arrowright,o=t.keyCode==Mr.arrowleft;if(!n&&!o)return;const s=r.contentLanguageDirection;let a=!1;a="ltr"===s&&n||"rtl"===s&&o?this._handleForwardMovement(t):this._handleBackwardMovement(t),!0===a&&e.stop()}),{context:"$text",priority:"highest"}),this._isNextGravityRestorationSkipped=!1,this.listenTo(i,"change:range",((e,t)=>{this._isNextGravityRestorationSkipped?this._isNextGravityRestorationSkipped=!1:this._isGravityOverridden&&(!t.directChange&&Bf(i.getFirstPosition(),this.attributes)||this._restoreGravity())}))}registerAttribute(e){this.attributes.add(e)}_handleForwardMovement(e){const t=this.attributes,n=this.editor.model.document.selection,r=n.getFirstPosition();return!(this._isGravityOverridden||r.isAtStart&&If(n,t)||!Bf(r,t)||(Rf(e),this._overrideGravity(),0))}_handleBackwardMovement(e){const t=this.attributes,n=this.editor.model,r=n.document.selection,i=r.getFirstPosition();return this._isGravityOverridden?(Rf(e),this._restoreGravity(),zf(n,t,i),!0):i.isAtStart?!!If(r,t)&&(Rf(e),zf(n,t,i),!0):!!function(e,t){return Bf(e.getShiftedBy(-1),t)}(i,t)&&(i.isAtEnd&&!If(r,t)&&Bf(i,t)?(Rf(e),zf(n,t,i),!0):(this._isNextGravityRestorationSkipped=!0,this._overrideGravity(),!1))}get _isGravityOverridden(){return!!this._overrideUid}_overrideGravity(){this._overrideUid=this.editor.model.change((e=>e.overrideSelectionGravity()))}_restoreGravity(){this.editor.model.change((e=>{e.restoreSelectionGravity(this._overrideUid),this._overrideUid=null}))}}function If(e,t){for(const n of t)if(e.hasAttribute(n))return!0;return!1}function zf(e,t,n){const r=n.nodeBefore;e.change((e=>{r?e.setSelectionAttribute(r.getAttributes()):e.removeSelectionAttribute(t)}))}function Rf(e){e.preventDefault()}function Bf(e,t){const{nodeBefore:n,nodeAfter:r}=e;for(const e of t){const t=n?n.getAttribute(e):void 0;if((r?r.getAttribute(e):void 0)!==t)return!0}return!1}var Ff=/[\\^$.*+?()[\]{}|]/g,Yf=RegExp(Ff.source);const Hf={copyright:{from:"(c)",to:"©"},registeredTrademark:{from:"(r)",to:"®"},trademark:{from:"(tm)",to:"™"},oneHalf:{from:/(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i,to:[null,"½",null]},oneThird:{from:/(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i,to:[null,"⅓",null]},twoThirds:{from:/(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i,to:[null,"⅔",null]},oneForth:{from:/(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i,to:[null,"¼",null]},threeQuarters:{from:/(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i,to:[null,"¾",null]},lessThanOrEqual:{from:"<=",to:"≤"},greaterThanOrEqual:{from:">=",to:"≥"},notEqual:{from:"!=",to:"≠"},arrowLeft:{from:"<-",to:"←"},arrowRight:{from:"->",to:"→"},horizontalEllipsis:{from:"...",to:"…"},enDash:{from:/(^| )(--)( )$/,to:[null,"–",null]},emDash:{from:/(^| )(---)( )$/,to:[null,"—",null]},quotesPrimary:{from:Zf('"'),to:[null,"“",null,"”"]},quotesSecondary:{from:Zf("'"),to:[null,"‘",null,"’"]},quotesPrimaryEnGb:{from:Zf("'"),to:[null,"‘",null,"’"]},quotesSecondaryEnGb:{from:Zf('"'),to:[null,"“",null,"”"]},quotesPrimaryPl:{from:Zf('"'),to:[null,"„",null,"”"]},quotesSecondaryPl:{from:Zf("'"),to:[null,"‚",null,"’"]}},$f={symbols:["copyright","registeredTrademark","trademark"],mathematical:["oneHalf","oneThird","twoThirds","oneForth","threeQuarters","lessThanOrEqual","greaterThanOrEqual","notEqual","arrowLeft","arrowRight"],typography:["horizontalEllipsis","enDash","emDash"],quotes:["quotesPrimary","quotesSecondary"]},Uf=["symbols","mathematical","typography","quotes"];function Wf(e){return"string"==typeof e?new RegExp(`(${function(e){return(e=No(e))&&Yf.test(e)?e.replace(Ff,"\\$&"):e}(e)})$`):e}function Vf(e){return"string"==typeof e?()=>[e]:e instanceof Array?()=>e:e}function qf(e){return(e.textNode?e.textNode:e.nodeAfter).getAttributes()}function Zf(e){return new RegExp(`(^|\\s)(${e})([^${e}]*)(${e})$`)}function Gf(e,t,n,r){return r.createRange(Kf(e,t,n,!0,r),Kf(e,t,n,!1,r))}function Kf(e,t,n,r,i){let o=e.textNode||(r?e.nodeBefore:e.nodeAfter),s=null;for(;o&&o.getAttribute(t)==n;)s=o,o=r?o.previousSibling:o.nextSibling;return s?i.createPositionAt(s,r?"before":"after"):e}function*Qf(e,t){for(const n of t)n&&e.getAttributeProperties(n[0]).copyOnEnter&&(yield n)}class Jf extends Gi{execute(){this.editor.model.change((e=>{this.enterBlock(e),this.fire("afterExecute",{writer:e})}))}enterBlock(e){const t=this.editor.model,n=t.document.selection,r=t.schema,i=n.isCollapsed,o=n.getFirstRange(),s=o.start.parent,a=o.end.parent;if(r.isLimit(s)||r.isLimit(a))return i||s!=a||t.deleteContent(n),!1;if(i){const t=Qf(e.model.schema,n.getAttributes());return Xf(e,o.start),e.setSelectionAttribute(t),!0}{const r=!(o.start.isAtStart&&o.end.isAtEnd),i=s==a;if(t.deleteContent(n,{leaveUnmerged:r}),r){if(i)return Xf(e,n.focus),!0;e.setSelection(a,0)}}return!1}}function Xf(e,t){e.split(t),e.setSelection(t.parent.nextSibling,0)}const em={insertParagraph:{isSoft:!1},insertLineBreak:{isSoft:!0}};class tm extends fa{constructor(e){super(e);const t=this.document;let n=!1;t.on("keydown",((e,t)=>{n=t.shiftKey})),t.on("beforeinput",((r,i)=>{if(!this.isEnabled)return;let o=i.inputType;u.isSafari&&n&&"insertParagraph"==o&&(o="insertLineBreak");const s=i.domEvent,a=em[o];if(!a)return;const l=new fs(t,"enter",i.targetRanges[0]);t.fire(l,new ga(e,s,{isSoft:a.isSoft})),l.stop.called&&r.stop()}))}observe(){}stopObserving(){}}class nm extends qi{static get pluginName(){return"Enter"}init(){const e=this.editor,t=e.editing.view,n=t.document;t.addObserver(tm),e.commands.add("enter",new Jf(e)),this.listenTo(n,"enter",((r,i)=>{n.isComposing||i.preventDefault(),i.isSoft||(e.execute("enter"),t.scrollToTheSelection())}),{priority:"low"})}}class rm extends Gi{execute(){const e=this.editor.model,t=e.document;e.change((n=>{!function(e,t,n){const r=n.isCollapsed,i=n.getFirstRange(),o=i.start.parent,s=i.end.parent,a=o==s;if(r){const r=Qf(e.schema,n.getAttributes());im(e,t,i.end),t.removeSelectionAttribute(n.getAttributeKeys()),t.setSelectionAttribute(r)}else{const r=!(i.start.isAtStart&&i.end.isAtEnd);e.deleteContent(n,{leaveUnmerged:r}),a?im(e,t,n.focus):r&&t.setSelection(s,0)}}(e,n,t.selection),this.fire("afterExecute",{writer:n})}))}refresh(){const e=this.editor.model,t=e.document;this.isEnabled=function(e,t){if(t.rangeCount>1)return!1;const n=t.anchor;if(!n||!e.checkChild(n,"softBreak"))return!1;const r=t.getFirstRange(),i=r.start.parent,o=r.end.parent;return!om(i,e)&&!om(o,e)||i===o}(e.schema,t.selection)}}function im(e,t,n){const r=t.createElement("softBreak");e.insertContent(r,n),t.setSelection(r,"after")}function om(e,t){return!e.is("rootElement")&&(t.isLimit(e)||om(e.parent,t))}class sm extends qi{static get pluginName(){return"ShiftEnter"}init(){const e=this.editor,t=e.model.schema,n=e.conversion,r=e.editing.view,i=r.document;t.register("softBreak",{allowWhere:"$text",isInline:!0}),n.for("upcast").elementToElement({model:"softBreak",view:"br"}),n.for("downcast").elementToElement({model:"softBreak",view:(e,{writer:t})=>t.createEmptyElement("br")}),r.addObserver(tm),e.commands.add("shiftEnter",new rm(e)),this.listenTo(i,"enter",((t,n)=>{i.isComposing||n.preventDefault(),n.isSoft&&(e.execute("shiftEnter"),r.scrollToTheSelection())}),{priority:"low"})}}class am extends(O()){constructor(){super(...arguments),this._stack=[]}add(e,t){const n=this._stack,r=n[0];this._insertDescriptor(e);const i=n[0];r===i||lm(r,i)||this.fire("change:top",{oldDescriptor:r,newDescriptor:i,writer:t})}remove(e,t){const n=this._stack,r=n[0];this._removeDescriptor(e);const i=n[0];r===i||lm(r,i)||this.fire("change:top",{oldDescriptor:r,newDescriptor:i,writer:t})}_insertDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e.id));if(lm(e,t[n]))return;n>-1&&t.splice(n,1);let r=0;for(;t[r]&&cm(t[r],e);)r++;t.splice(r,0,e)}_removeDescriptor(e){const t=this._stack,n=t.findIndex((t=>t.id===e));n>-1&&t.splice(n,1)}}function lm(e,t){return e&&t&&e.priority==t.priority&&um(e.classes)==um(t.classes)}function cm(e,t){return e.priority>t.priority||!(e.priorityum(t.classes)}function um(e){return Array.isArray(e)?e.sort().join(","):e}const dm='',hm="ck-widget",pm="ck-widget_selected";function fm(e){return!!e.is("element")&&!!e.getCustomProperty("widget")}function mm(e,t,n={}){if(!e.is("containerElement"))throw new k("widget-to-widget-wrong-element-type",null,{element:e});return t.setAttribute("contenteditable","false",e),t.addClass(hm,e),t.setCustomProperty("widget",!0,e),e.getFillerOffset=wm,t.setCustomProperty("widgetLabel",[],e),n.label&&function(e,t){e.getCustomProperty("widgetLabel").push(t)}(e,n.label),n.hasSelectionHandle&&function(e,t){const n=t.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(e){const t=this.toDomElement(e),n=new xi;return n.set("content",dm),n.render(),t.appendChild(n.element),t}));t.insert(t.createPositionAt(e,0),n),t.addClass(["ck-widget_with-selection-handle"],e)}(e,t),ym(e,t),e}function gm(e,t,n){if(t.classes&&n.addClass(Lr(t.classes),e),t.attributes)for(const r in t.attributes)n.setAttribute(r,t.attributes[r],e)}function bm(e,t,n){if(t.classes&&n.removeClass(Lr(t.classes),e),t.attributes)for(const r in t.attributes)n.removeAttribute(r,e)}function ym(e,t,n=gm,r=bm){const i=new am;i.on("change:top",((t,i)=>{i.oldDescriptor&&r(e,i.oldDescriptor,i.writer),i.newDescriptor&&n(e,i.newDescriptor,i.writer)})),t.setCustomProperty("addHighlight",((e,t,n)=>i.add(t,n)),e),t.setCustomProperty("removeHighlight",((e,t,n)=>i.remove(t,n)),e)}function vm(e,t,n={}){return t.addClass(["ck-editor__editable","ck-editor__nested-editable"],e),t.setAttribute("role","textbox",e),n.label&&t.setAttribute("aria-label",n.label,e),t.setAttribute("contenteditable",e.isReadOnly?"false":"true",e),e.on("change:isReadOnly",((n,r,i)=>{t.setAttribute("contenteditable",i?"false":"true",e)})),e.on("change:isFocused",((n,r,i)=>{i?t.addClass("ck-editor__nested-editable_focused",e):t.removeClass("ck-editor__nested-editable_focused",e)})),ym(e,t),e}function _m(e,t){const n=e.getSelectedElement();if(n){const r=Cm(e);if(r)return t.createRange(t.createPositionAt(n,r))}return Fd(e,t)}function wm(){return null}const km="widget-type-around";function xm(e,t,n){return!!e&&fm(e)&&!n.isInline(t)}function Cm(e){return e.getAttribute(km)}var jm=o(4921);Kr()(jm.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),jm.Z.locals;const Am=["before","after"],Sm=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,Mm="ck-widget__type-around_disabled";class Nm extends qi{constructor(){super(...arguments),this._currentFakeCaretModelElement=null}static get pluginName(){return"WidgetTypeAround"}static get requires(){return[nm,Df]}init(){const e=this.editor,t=e.editing.view;this.on("change:isEnabled",((n,r,i)=>{t.change((e=>{for(const n of t.document.roots)i?e.removeClass(Mm,n):e.addClass(Mm,n)})),i||e.model.change((e=>{e.removeSelectionAttribute(km)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){super.destroy(),this._currentFakeCaretModelElement=null}_insertParagraph(e,t){const n=this.editor,r=n.editing.view,i=n.model.schema.getAttributesWithProperty(e,"copyOnReplace",!0);n.execute("insertParagraph",{position:n.model.createPositionAt(e,t),attributes:i}),r.focus(),r.scrollToTheSelection()}_listenToIfEnabled(e,t,n,r){this.listenTo(e,t,((...e)=>{this.isEnabled&&n(...e)}),r)}_insertParagraphAccordingToFakeCaretPosition(){const e=this.editor.model.document.selection,t=Cm(e);if(!t)return!1;const n=e.getSelectedElement();return this._insertParagraph(n,t),!0}_enableTypeAroundUIInjection(){const e=this.editor,t=e.model.schema,n=e.locale.t,r={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};e.editing.downcastDispatcher.on("insert",((e,i,o)=>{const s=o.mapper.toViewElement(i.item);s&&xm(s,i.item,t)&&(function(e,t,n){const r=e.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(e){const n=this.toDomElement(e);return function(e,t){for(const n of Am){const r=new Xr({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:t[n],"aria-hidden":"true"},children:[e.ownerDocument.importNode(Sm,!0)]});e.appendChild(r.render())}}(n,t),function(e){const t=new Xr({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});e.appendChild(t.render())}(n),n}));e.insert(e.createPositionAt(n,"end"),r)}(o.writer,r,s),s.getCustomProperty("widgetLabel").push((()=>this.isEnabled?n("Press Enter to type after or press Shift + Enter to type before the widget"):"")))}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const e=this.editor,t=e.model,n=t.document.selection,r=t.schema,i=e.editing.view;function o(e){return`ck-widget_type-around_show-fake-caret_${e}`}this._listenToIfEnabled(i.document,"arrowKey",((e,t)=>{this._handleArrowKeyPress(e,t)}),{context:[fm,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",((t,n)=>{n.directChange&&e.model.change((e=>{e.removeSelectionAttribute(km)}))})),this._listenToIfEnabled(t.document,"change:data",(()=>{const t=n.getSelectedElement();t&&xm(e.editing.mapper.toViewElement(t),t,r)||e.model.change((e=>{e.removeSelectionAttribute(km)}))})),this._listenToIfEnabled(e.editing.downcastDispatcher,"selection",((e,t,n)=>{const i=n.writer;if(this._currentFakeCaretModelElement){const e=n.mapper.toViewElement(this._currentFakeCaretModelElement);e&&(i.removeClass(Am.map(o),e),this._currentFakeCaretModelElement=null)}const s=t.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!xm(a,s,r))return;const l=Cm(t.selection);l&&(i.addClass(o(l),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(e.ui.focusTracker,"change:isFocused",((t,n,r)=>{r||e.model.change((e=>{e.removeSelectionAttribute(km)}))}))}_handleArrowKeyPress(e,t){const n=this.editor,r=n.model,i=r.document.selection,o=r.schema,s=n.editing.view,a=function(e,t){const n=Or(e,t);return"down"===n||"right"===n}(t.keyCode,n.locale.contentLanguageDirection),l=s.document.selection.getSelectedElement();let c;xm(l,n.editing.mapper.toModelElement(l),o)?c=this._handleArrowKeyPressOnSelectedWidget(a):i.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):t.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(t.preventDefault(),e.stop())}_handleArrowKeyPressOnSelectedWidget(e){const t=this.editor.model,n=Cm(t.document.selection);return t.change((t=>n?n!==(e?"after":"before")&&(t.removeSelectionAttribute(km),!0):(t.setSelectionAttribute(km,e?"after":"before"),!0)))}_handleArrowKeyPressWhenSelectionNextToAWidget(e){const t=this.editor,n=t.model,r=n.schema,i=t.plugins.get("Widget"),o=i._getObjectElementNextToSelection(e);return!!xm(t.editing.mapper.toViewElement(o),o,r)&&(n.change((t=>{i._setSelectionOverElement(o),t.setSelectionAttribute(km,e?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(e){const t=this.editor,n=t.model,r=n.schema,i=t.editing.mapper,o=n.document.selection,s=e?o.getLastPosition().nodeBefore:o.getFirstPosition().nodeAfter;return!!xm(i.toViewElement(s),s,r)&&(n.change((t=>{t.setSelection(s,"on"),t.setSelectionAttribute(km,e?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const e=this.editor,t=e.editing.view;this._listenToIfEnabled(t.document,"mousedown",((n,r)=>{const i=r.domTarget.closest(".ck-widget__type-around__button");if(!i)return;const o=function(e){return e.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(i),s=function(e,t){const n=e.closest(".ck-widget");return t.mapDomToView(n)}(i,t.domConverter),a=e.editing.mapper.toModelElement(s);this._insertParagraph(a,o),r.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const e=this.editor,t=e.model.document.selection,n=e.editing.view;this._listenToIfEnabled(n.document,"enter",((n,r)=>{if("atTarget"!=n.eventPhase)return;const i=t.getSelectedElement(),o=e.editing.mapper.toViewElement(i),s=e.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:xm(o,i,s)&&(this._insertParagraph(i,r.isSoft?"before":"after"),a=!0),a&&(r.preventDefault(),n.stop())}),{context:fm})}_enableInsertingParagraphsOnTypingKeystroke(){const e=this.editor.editing.view.document;this._listenToIfEnabled(e,"insertText",((t,n)=>{this._insertParagraphAccordingToFakeCaretPosition()&&(n.selection=e.selection)}),{priority:"high"}),u.isAndroid?this._listenToIfEnabled(e,"keydown",((e,t)=>{229==t.keyCode&&this._insertParagraphAccordingToFakeCaretPosition()})):this._listenToIfEnabled(e,"compositionstart",(()=>{this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const e=this.editor,t=e.editing.view,n=e.model,r=n.schema;this._listenToIfEnabled(t.document,"delete",((t,i)=>{if("atTarget"!=t.eventPhase)return;const o=Cm(n.document.selection);if(!o)return;const s=i.direction,a=n.document.selection.getSelectedElement(),l="forward"==s;if("before"===o===l)e.execute("delete",{selection:n.createSelection(a,"on")});else{const t=r.getNearestSelectionRange(n.createPositionAt(a,o),s);if(t)if(t.isCollapsed){const i=n.createSelection(t.start);if(n.modifySelection(i,{direction:s}),i.focus.isEqual(t.start)){const e=function(e,t){let n=t;for(const r of t.getAncestors({parentFirst:!0})){if(r.childCount>1||e.isLimit(r))break;n=r}return n}(r,t.start.parent);n.deleteContent(n.createSelection(e,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(t),e.execute(l?"deleteForward":"delete")}))}else n.change((n=>{n.setSelection(t),e.execute(l?"deleteForward":"delete")}))}i.preventDefault(),t.stop()}),{context:fm})}_enableInsertContentIntegration(){const e=this.editor,t=this.editor.model,n=t.document.selection;this._listenToIfEnabled(e.model,"insertContent",((e,[r,i])=>{if(i&&!i.is("documentSelection"))return;const o=Cm(n);return o?(e.stop(),t.change((e=>{const i=n.getSelectedElement(),s=t.createPositionAt(i,o),a=e.createSelection(s),l=t.insertContent(r,a);return e.setSelection(a),l}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"insertObject",((e,n)=>{const[,r,i={}]=n;if(r&&!r.is("documentSelection"))return;const o=Cm(t);o&&(i.findOptimalPosition=o,n[3]=i)}),{priority:"high"})}_enableDeleteContentIntegration(){const e=this.editor,t=this.editor.model.document.selection;this._listenToIfEnabled(e.model,"deleteContent",((e,[n])=>{n&&!n.is("documentSelection")||Cm(t)&&e.stop()}),{priority:"high"})}}function Em(e,t,n){const r=e.schema,i=e.createRangeIn(t.root),o="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:e,item:s,type:a}of i.getWalker({startPosition:t,direction:n})){if(r.isLimit(s)&&!r.isInline(s))return e;if(a==o&&r.isBlock(s))return null}return null}function Dm(e,t,n){const r="backward"==n?t.end:t.start;if(e.checkChild(r,"$text"))return r;for(const{nextPosition:r}of t.getWalker({direction:n}))if(e.checkChild(r,"$text"))return r;return null}var Tm=o(3488);Kr()(Tm.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Tm.Z.locals;class Om extends qi{constructor(){super(...arguments),this._previouslySelected=new Set}static get pluginName(){return"Widget"}static get requires(){return[Nm,Df]}init(){const e=this.editor,t=e.editing.view,n=t.document;this.editor.editing.downcastDispatcher.on("selection",((t,n,r)=>{const i=r.writer,o=n.selection;if(o.isCollapsed)return;const s=o.getSelectedElement();if(!s)return;const a=e.editing.mapper.toViewElement(s);var l;fm(a)&&r.consumable.consume(o,"selection")&&i.setSelection(i.createRangeOn(a),{fake:!0,label:(l=a,l.getCustomProperty("widgetLabel").reduce(((e,t)=>"function"==typeof t?e?e+". "+t():t():e?e+". "+t:t),""))})})),this.editor.editing.downcastDispatcher.on("selection",((e,t,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const r=n.writer,i=r.document.selection;let o=null;for(const e of i.getRanges())for(const t of e){const e=t.item;fm(e)&&!Lm(e,o)&&(r.addClass(pm,e),this._previouslySelected.add(e),o=e)}}),{priority:"low"}),t.addObserver(Gd),this.listenTo(n,"mousedown",((...e)=>this._onMousedown(...e))),this.listenTo(n,"arrowKey",((...e)=>{this._handleSelectionChangeOnArrowKeyPress(...e)}),{context:[fm,"$text"]}),this.listenTo(n,"arrowKey",((...e)=>{this._preventDefaultOnArrowKeyPress(...e)}),{context:"$root"}),this.listenTo(n,"arrowKey",function(e){const t=e.model;return(n,r)=>{const i=r.keyCode==Mr.arrowup,o=r.keyCode==Mr.arrowdown,s=r.shiftKey,a=t.document.selection;if(!i&&!o)return;const l=o;if(s&&function(e,t){return!e.isCollapsed&&e.isBackward==t}(a,l))return;const c=function(e,t,n){const r=e.model;if(n){const e=t.isCollapsed?t.focus:t.getLastPosition(),n=Em(r,e,"forward");if(!n)return null;const i=r.createRange(e,n),o=Dm(r.schema,i,"backward");return o?r.createRange(e,o):null}{const e=t.isCollapsed?t.focus:t.getFirstPosition(),n=Em(r,e,"backward");if(!n)return null;const i=r.createRange(n,e),o=Dm(r.schema,i,"forward");return o?r.createRange(o,e):null}}(e,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(s)return}(c.isCollapsed||function(e,t,n){const r=e.model,i=e.view.domConverter;if(n){const e=r.createSelection(t.start);r.modifySelection(e),e.focus.isAtEnd||t.start.isEqual(e.focus)||(t=r.createRange(e.focus,t.end))}const o=e.mapper.toViewRange(t),s=i.viewRangeToDom(o),a=er.getDomRangeRects(s);let l;for(const e of a)if(void 0!==l){if(Math.round(e.top)>=l)return!1;l=Math.max(l,Math.round(e.bottom))}else l=Math.round(e.bottom);return!0}(e,c,l))&&(t.change((e=>{const n=l?c.end:c.start;if(s){const r=t.createSelection(a.anchor);r.setFocus(n),e.setSelection(r)}else e.setSelection(n)})),n.stop(),r.preventDefault(),r.stopPropagation())}}}(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",((e,t)=>{this._handleDelete("forward"==t.direction)&&(t.preventDefault(),e.stop())}),{context:"$root"})}_onMousedown(e,t){const n=this.editor,r=n.editing.view,i=r.document;let o=t.target;if(function(e){let t=e;for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if(fm(t))return!1;t=t.parent}return!1}(o)){if((u.isSafari||u.isGecko)&&t.domEvent.detail>=3){const e=n.editing.mapper,r=o.is("attributeElement")?o.findAncestor((e=>!e.is("attributeElement"))):o,i=e.toModelElement(r);t.preventDefault(),this.editor.model.change((e=>{e.setSelection(i,"in")}))}return}if(!fm(o)&&(o=o.findAncestor(fm),!o))return;u.isAndroid&&t.preventDefault(),i.isFocused||r.focus();const s=n.editing.mapper.toModelElement(o);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(e,t){const n=t.keyCode,r=this.editor.model,i=r.schema,o=r.document.selection,s=o.getSelectedElement(),a=Or(n,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(s&&i.isObject(s)){const n=l?o.getLastPosition():o.getFirstPosition(),s=i.getNearestSelectionRange(n,l?"forward":"backward");return void(s&&(r.change((e=>{e.setSelection(s)})),t.preventDefault(),e.stop()))}if(!o.isCollapsed&&!t.shiftKey){const n=o.getFirstPosition(),s=o.getLastPosition(),a=n.nodeAfter,c=s.nodeBefore;return void((a&&i.isObject(a)||c&&i.isObject(c))&&(r.change((e=>{e.setSelection(l?s:n)})),t.preventDefault(),e.stop()))}if(!o.isCollapsed)return;const u=this._getObjectElementNextToSelection(l);if(u&&i.isObject(u)){if(i.isInline(u)&&c)return;this._setSelectionOverElement(u),t.preventDefault(),e.stop()}}_preventDefaultOnArrowKeyPress(e,t){const n=this.editor.model,r=n.schema,i=n.document.selection.getSelectedElement();i&&r.isObject(i)&&(t.preventDefault(),e.stop())}_handleDelete(e){const t=this.editor.model.document.selection;if(!this.editor.model.canEditAt(t))return;if(!t.isCollapsed)return;const n=this._getObjectElementNextToSelection(e);return n?(this.editor.model.change((e=>{let r=t.anchor.parent;for(;r.isEmpty;){const t=r;r=t.parent,e.remove(t)}this._setSelectionOverElement(n)})),!0):void 0}_setSelectionOverElement(e){this.editor.model.change((t=>{t.setSelection(t.createRangeOn(e))}))}_getObjectElementNextToSelection(e){const t=this.editor.model,n=t.schema,r=t.document.selection,i=t.createSelection(r);if(t.modifySelection(i,{direction:e?"forward":"backward"}),i.isEqual(r))return null;const o=e?i.focus.nodeBefore:i.focus.nodeAfter;return o&&n.isObject(o)?o:null}_clearPreviouslySelectedWidgets(e){for(const t of this._previouslySelected)e.removeClass(pm,t);this._previouslySelected.clear()}}function Lm(e,t){return!!t&&Array.from(e.getAncestors()).includes(t)}class Pm extends qi{constructor(){super(...arguments),this._toolbarDefinitions=new Map}static get requires(){return[Vp]}static get pluginName(){return"WidgetToolbarRepository"}init(){const e=this.editor;if(e.plugins.has("BalloonToolbar")){const t=e.plugins.get("BalloonToolbar");this.listenTo(t,"show",(t=>{(function(e){const t=e.getSelectedElement();return!(!t||!fm(t))})(e.editing.view.document.selection)&&t.stop()}),{priority:"high"})}this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(e.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const e of this._toolbarDefinitions.values())e.view.destroy()}register(e,{ariaLabel:t,items:n,getRelatedElement:r,balloonClassName:i="ck-toolbar-container"}){if(!n.length)return void x("widget-toolbar-no-items",{toolbarId:e});const o=this.editor,s=o.t,a=new sh(o.locale);if(a.ariaLabel=t||s("Widget toolbar"),this._toolbarDefinitions.has(e))throw new k("widget-toolbar-duplicated",this,{toolbarId:e});const l={view:a,getRelatedElement:r,balloonClassName:i,itemsConfig:n,initialized:!1};o.ui.addToolbar(a,{isContextual:!0,beforeFocus:()=>{const e=r(o.editing.view.document.selection);e&&this._showToolbar(l,e)},afterBlur:()=>{this._hideToolbar(l)}}),this._toolbarDefinitions.set(e,l)}_updateToolbarsVisibility(){let e=0,t=null,n=null;for(const r of this._toolbarDefinitions.values()){const i=r.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&i)if(this.editor.ui.focusTracker.isFocused){const o=i.getAncestors().length;o>e&&(e=o,t=i,n=r)}else this._isToolbarVisible(r)&&this._hideToolbar(r);else this._isToolbarInBalloon(r)&&this._hideToolbar(r)}n&&this._showToolbar(n,t)}_hideToolbar(e){this._balloon.remove(e.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(e,t){this._isToolbarVisible(e)?Im(this.editor,t):this._isToolbarInBalloon(e)||(e.initialized||(e.initialized=!0,e.view.fillFromConfig(e.itemsConfig,this.editor.ui.componentFactory)),this._balloon.add({view:e.view,position:zm(this.editor,t),balloonClassName:e.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const e of this._toolbarDefinitions.values())if(this._isToolbarVisible(e)){const t=e.getRelatedElement(this.editor.editing.view.document.selection);Im(this.editor,t)}})))}_isToolbarVisible(e){return this._balloon.visibleView===e.view}_isToolbarInBalloon(e){return this._balloon.hasView(e.view)}}function Im(e,t){const n=e.plugins.get("ContextualBalloon"),r=zm(e,t);n.updatePosition(r)}function zm(e,t){const n=e.editing.view,r=cp.defaultPositions;return{target:n.domConverter.mapViewToDom(t),positions:[r.northArrowSouth,r.northArrowSouthWest,r.northArrowSouthEast,r.southArrowNorth,r.southArrowNorthWest,r.southArrowNorthEast,r.viewportStickyNorth]}}Z(),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable,Z();var Rm=o(8506);Kr()(Rm.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Rm.Z.locals;var Bm=o(903);Kr()(Bm.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Bm.Z.locals;class Fm extends qi{static get pluginName(){return"DragDrop"}static get requires(){return[bf,Om]}init(){const e=this.editor,t=e.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=bp((e=>this._updateDropMarker(e)),40),this._removeDropMarkerDelayed=$r((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=$r((()=>this._clearDraggableAttributes()),40),e.plugins.has("DragDropExperimental")?this.forceDisabled("DragDropExperimental"):(t.addObserver(ff),t.addObserver(Gd),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(e,"change:isReadOnly",((e,t,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((e,t,n)=>{n||this._finalizeDragging(!1)})),u.isAndroid&&this.forceDisabled("noAndroidSupport"))}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._updateDropMarkerThrottled.cancel(),this._removeDropMarkerDelayed.cancel(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const e=this.editor,t=e.model,n=t.document,r=e.editing.view,i=r.document;this.listenTo(i,"dragstart",((r,o)=>{const s=n.selection;if(o.target&&o.target.is("editableElement"))return void o.preventDefault();const a=o.target?$m(o.target):null;if(a){const n=e.editing.mapper.toModelElement(a);this._draggedRange=Ul.fromRange(t.createRangeOn(n)),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!i.selection.isCollapsed){const e=i.selection.getSelectedElement();e&&fm(e)||(this._draggedRange=Ul.fromRange(s.getFirstRange()))}if(!this._draggedRange)return void o.preventDefault();this._draggingUid=y();const l=this.isEnabled&&e.model.canEditAt(this._draggedRange);o.dataTransfer.effectAllowed=l?"copyMove":"copy",o.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=t.createSelection(this._draggedRange.toRange()),u=e.data.toView(t.getSelectedContent(c));i.fire("clipboardOutput",{dataTransfer:o.dataTransfer,content:u,method:"dragstart"}),l||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(i,"dragend",((e,t)=>{this._finalizeDragging(!t.dataTransfer.isCanceled&&"move"==t.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(i,"dragenter",(()=>{this.isEnabled&&r.focus()})),this.listenTo(i,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(i,"dragging",((t,n)=>{if(!this.isEnabled)return void(n.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const r=Ym(e,n.targetRanges,n.target);e.model.canEditAt(r)?(this._draggedRange||(n.dataTransfer.dropEffect="copy"),u.isGecko||("copy"==n.dataTransfer.effectAllowed?n.dataTransfer.dropEffect="copy":["all","copyMove"].includes(n.dataTransfer.effectAllowed)&&(n.dataTransfer.dropEffect="move")),r&&this._updateDropMarkerThrottled(r)):n.dataTransfer.dropEffect="none"}),{priority:"low"})}_setupClipboardInputIntegration(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"clipboardInput",((t,n)=>{if("drop"!=n.method)return;const r=Ym(e,n.targetRanges,n.target);return this._removeDropMarker(),r&&e.model.canEditAt(r)?(this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid=""),"move"==Hm(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(r,!0)?(this._finalizeDragging(!1),void t.stop()):void(n.targetRanges=[e.editing.mapper.toViewRange(r)])):(this._finalizeDragging(!1),void t.stop())}),{priority:"high"})}_setupContentInsertionIntegration(){const e=this.editor.plugins.get(bf);e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const n=t.targetRanges.map((e=>this.editor.editing.mapper.toModelRange(e)));this.editor.model.change((e=>e.setSelection(n)))}),{priority:"high"}),e.on("contentInsertion",((e,t)=>{if(!this.isEnabled||"drop"!==t.method)return;const n="move"==Hm(t.dataTransfer),r=!t.resultRange||!t.resultRange.isCollapsed;this._finalizeDragging(r&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const e=this.editor,t=e.editing.view,n=t.document;this.listenTo(n,"mousedown",((r,i)=>{if(u.isAndroid||!i)return;this._clearDraggableAttributesDelayed.cancel();let o=$m(i.target);if(u.isBlink&&!o&&!n.selection.isCollapsed){const e=n.selection.getSelectedElement();if(!e||!fm(e)){const e=n.selection.editableElement;e&&!e.isReadOnly&&(o=e)}}o&&(t.change((e=>{e.setAttribute("draggable","true",o)})),this._draggableElement=e.editing.mapper.toModelElement(o))})),this.listenTo(n,"mouseup",(()=>{u.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const e=this.editor.editing;e.view.change((t=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&t.removeAttribute("draggable",e.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_setupDropMarker(){const e=this.editor;e.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),e.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(t,{writer:n})=>{if(e.model.schema.checkChild(t.markerRange.start,"$text"))return n.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(e){const t=this.toDomElement(e);return t.append("",e.createElement("span"),""),t}))}})}_updateDropMarker(e){const t=this.editor,n=t.model.markers;t.model.change((t=>{n.has("drop-target")?n.get("drop-target").getRange().isEqual(e)||t.updateMarker("drop-target",{range:e}):t.addMarker("drop-target",{range:e,usingOperation:!1,affectsData:!1})}))}_removeDropMarker(){const e=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),e.markers.has("drop-target")&&e.change((e=>{e.removeMarker("drop-target")}))}_finalizeDragging(e){const t=this.editor,n=t.model;this._removeDropMarker(),this._clearDraggableAttributes(),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._draggedRange&&(e&&this.isEnabled&&n.deleteContent(n.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function Ym(e,t,n){const r=e.model,i=e.editing.mapper;let o=null;const s=t?t[0].start:null;if(n.is("uiElement")&&(n=n.parent),o=function(e,t){const n=e.model,r=e.editing.mapper;if(fm(t))return n.createRangeOn(r.toModelElement(t));if(!t.is("editableElement")){const e=t.findAncestor((e=>fm(e)||e.is("editableElement")));if(fm(e))return n.createRangeOn(r.toModelElement(e))}return null}(e,n),o)return o;const a=function(e,t){const n=e.editing.mapper,r=e.editing.view,i=n.toModelElement(t);if(i)return i;const o=r.createPositionBefore(t),s=n.findMappedViewAncestor(o);return n.toModelElement(s)}(e,n),l=s?i.toModelPosition(s):null;return l?(o=function(e,t,n){const r=e.model;if(!r.schema.checkChild(n,"$block"))return null;const i=r.createPositionAt(n,0),o=t.path.slice(0,i.path.length),s=r.createPositionFromPath(t.root,o).nodeAfter;return s&&r.schema.isObject(s)?r.createRangeOn(s):null}(e,l,a),o||(o=r.schema.getNearestSelectionRange(l,u.isGecko?"forward":"backward"),o||function(e,t){const n=e.model;let r=t;for(;r;){if(n.schema.isObject(r))return n.createRangeOn(r);r=r.parent}return null}(e,l.parent))):function(e,t){const n=e.model,r=n.schema,i=n.createPositionAt(t,0);return r.getNearestSelectionRange(i,"forward")}(e,a)}function Hm(e){return u.isGecko?e.dropEffect:["all","copyMove"].includes(e.effectAllowed)?"move":"copy"}function $m(e){if(e.is("editableElement"))return null;if(e.hasClass("ck-widget__selection-handle"))return e.findAncestor(fm);if(fm(e))return e;const t=e.findAncestor((e=>fm(e)||e.is("editableElement")));return fm(t)?t:null}class Um extends qi{static get pluginName(){return"PastePlainText"}static get requires(){return[bf]}init(){const e=this.editor,t=e.model,n=e.editing.view,r=n.document,i=t.document.selection;let o=!1;n.addObserver(ff),this.listenTo(r,"keydown",((e,t)=>{o=t.shiftKey})),e.plugins.get(bf).on("contentInsertion",((e,n)=>{(o||function(e,t){if(e.childCount>1)return!1;const n=e.getChild(0);return!t.isObject(n)&&0==Array.from(n.getAttributeKeys()).length}(n.content,t.schema))&&t.change((e=>{const r=Array.from(i.getAttributes()).filter((([e])=>t.schema.getAttributeProperties(e).isFormatting));i.isCollapsed||t.deleteContent(i,{doNotAutoparagraph:!0}),r.push(...i.getAttributes());const o=e.createRangeIn(n.content);for(const t of o.getItems())t.is("$textProxy")&&e.setAttributes(r,t)}))}))}}class Wm extends qi{static get pluginName(){return"Clipboard"}static get requires(){return[bf,Fm,Um]}}ar("px"),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;class Vm extends Gi{constructor(e){super(e),this.affectsData=!1}execute(){const e=this.editor.model,t=e.document.selection;let n=e.schema.getLimitElement(t);if(t.containsEntireContent(n)||!qm(e.schema,n))do{if(n=n.parent,!n)return}while(!qm(e.schema,n));e.change((e=>{e.setSelection(n,"in")}))}}function qm(e,t){return e.isLimit(t)&&(e.checkChild(t,"$text")||e.checkChild(t,"paragraph"))}const Zm=Dr("Ctrl+A");class Gm extends qi{static get pluginName(){return"SelectAllEditing"}init(){const e=this.editor,t=e.editing.view.document;e.commands.add("selectAll",new Vm(e)),this.listenTo(t,"keydown",((t,n)=>{Er(n)===Zm&&(e.execute("selectAll"),n.preventDefault())}))}}class Km extends qi{static get pluginName(){return"SelectAllUI"}init(){const e=this.editor;e.ui.componentFactory.add("selectAll",(t=>{const n=e.commands.get("selectAll"),r=new ji(t),i=t.t;return r.set({label:i("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),r.bind("isEnabled").to(n,"isEnabled"),this.listenTo(r,"execute",(()=>{e.execute("selectAll"),e.editing.view.focus()})),r}))}}class Qm extends qi{static get requires(){return[Gm,Km]}static get pluginName(){return"SelectAll"}}var Jm=Object.defineProperty,Xm=Object.getOwnPropertySymbols,eg=Object.prototype.hasOwnProperty,tg=Object.prototype.propertyIsEnumerable,ng=(e,t,n)=>t in e?Jm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class rg extends Gi{constructor(e){super(e),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this._isEnabledBasedOnSelection=!1,this.listenTo(e.data,"set",((e,t)=>{t[1]=((e,t)=>{for(var n in t||(t={}))eg.call(t,n)&&ng(e,n,t[n]);if(Xm)for(var n of Xm(t))tg.call(t,n)&&ng(e,n,t[n]);return e})({},t[1]);const n=t[1];n.batchType||(n.batchType={isUndoable:!1})}),{priority:"high"}),this.listenTo(e.data,"set",((e,t)=>{t[1].batchType.isUndoable||this.clearStack()}))}refresh(){this.isEnabled=this._stack.length>0}get createdBatches(){return this._createdBatches}addBatch(e){const t=this.editor.model.document.selection,n={ranges:t.hasOwnRange?Array.from(t.getRanges()):[],isBackward:t.isBackward};this._stack.push({batch:e,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(e,t,n){const r=this.editor.model,i=r.document,o=[],s=e.map((e=>e.getTransformedByOperations(n))),a=s.flat();for(const e of s){const t=e.filter((e=>e.root!=i.graveyard)).filter((e=>!og(e,a)));t.length&&(ig(t),o.push(t[0]))}o.length&&r.change((e=>{e.setSelection(o,{backward:t})}))}_undo(e,t){const n=this.editor.model,r=n.document;this._createdBatches.add(t);const i=e.operations.slice().filter((e=>e.isDocumentOperation));i.reverse();for(const e of i){const i=e.baseVersion+1,o=Array.from(r.history.getOperations(i)),s=Pu([e.getReversed()],o,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(let i of s){const o=i.affectedSelectable;o&&!n.canEditAt(o)&&(i=new ju(i.baseVersion)),t.addOperation(i),n.applyOperation(i),r.history.setOperationAsUndone(e,i)}}}}function ig(e){e.sort(((e,t)=>e.start.isBefore(t.start)?-1:1));for(let t=1;tt!==e&&t.containsRange(e,!0)))}class sg extends rg{execute(e=null){const t=e?this._stack.findIndex((t=>t.batch==e)):this._stack.length-1,n=this._stack.splice(t,1)[0],r=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(r,(()=>{this._undo(n.batch,r);const e=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,e),this.fire("revert",n.batch,r)})),this.refresh()}}class ag extends rg{execute(){const e=this._stack.pop(),t=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(t,(()=>{const n=e.batch.operations[e.batch.operations.length-1].baseVersion+1,r=this.editor.model.document.history.getOperations(n);this._restoreSelection(e.selection.ranges,e.selection.isBackward,r),this._undo(e.batch,t)})),this.refresh()}}class lg extends qi{constructor(){super(...arguments),this._batchRegistry=new WeakSet}static get pluginName(){return"UndoEditing"}init(){const e=this.editor;this._undoCommand=new sg(e),this._redoCommand=new ag(e),e.commands.add("undo",this._undoCommand),e.commands.add("redo",this._redoCommand),this.listenTo(e.model,"applyOperation",((e,t)=>{const n=t[0];if(!n.isDocumentOperation)return;const r=n.batch,i=this._redoCommand.createdBatches.has(r),o=this._undoCommand.createdBatches.has(r);this._batchRegistry.has(r)||(this._batchRegistry.add(r),r.isUndoable&&(i?this._undoCommand.addBatch(r):o||(this._undoCommand.addBatch(r),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((e,t,n)=>{this._redoCommand.addBatch(n)})),e.keystrokes.set("CTRL+Z","undo"),e.keystrokes.set("CTRL+Y","redo"),e.keystrokes.set("CTRL+SHIFT+Z","redo")}}const cg='',ug='';class dg extends qi{static get pluginName(){return"UndoUI"}init(){const e=this.editor,t=e.locale,n=e.t,r="ltr"==t.uiLanguageDirection?cg:ug,i="ltr"==t.uiLanguageDirection?ug:cg;this._addButton("undo",n("Undo"),"CTRL+Z",r),this._addButton("redo",n("Redo"),"CTRL+Y",i)}_addButton(e,t,n,r){const i=this.editor;i.ui.componentFactory.add(e,(o=>{const s=i.commands.get(e),a=new ji(o);return a.set({label:t,icon:r,keystroke:n,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{i.execute(e),i.editing.view.focus()})),a}))}}class hg extends qi{static get requires(){return[lg,dg]}static get pluginName(){return"Undo"}}class pg extends(Z()){constructor(){super();const e=new window.FileReader;this._reader=e,this._data=void 0,this.set("loaded",0),e.onprogress=e=>{this.loaded=e.loaded}}get error(){return this._reader.error}get data(){return this._data}read(e){const t=this._reader;return this.total=e.size,new Promise(((n,r)=>{t.onload=()=>{const e=t.result;this._data=e,n(e)},t.onerror=()=>{r("error")},t.onabort=()=>{r("aborted")},this._reader.readAsDataURL(e)}))}abort(){this._reader.abort()}}class fg extends qi{constructor(){super(...arguments),this.loaders=new Rr,this._loadersMap=new Map,this._pendingAction=null}static get pluginName(){return"FileRepository"}static get requires(){return[th]}init(){this.loaders.on("change",(()=>this._updatePendingAction())),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0))}getLoader(e){return this._loadersMap.get(e)||null}createLoader(e){if(!this.createUploadAdapter)return x("filerepository-no-upload-adapter"),null;const t=new mg(Promise.resolve(e),this.createUploadAdapter);return this.loaders.add(t),this._loadersMap.set(e,t),e instanceof Promise&&t.file.then((e=>{this._loadersMap.set(e,t)})).catch((()=>{})),t.on("change:uploaded",(()=>{let e=0;for(const t of this.loaders)e+=t.uploaded;this.uploaded=e})),t.on("change:uploadTotal",(()=>{let e=0;for(const t of this.loaders)t.uploadTotal&&(e+=t.uploadTotal);this.uploadTotal=e})),t}destroyLoader(e){const t=e instanceof mg?e:this.getLoader(e);t._destroy(),this.loaders.remove(t),this._loadersMap.forEach(((e,n)=>{e===t&&this._loadersMap.delete(n)}))}_updatePendingAction(){const e=this.editor.plugins.get(th);if(this.loaders.length){if(!this._pendingAction){const t=this.editor.t,n=e=>`${t("Upload in progress")} ${parseInt(e)}%.`;this._pendingAction=e.add(n(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",n)}}else e.remove(this._pendingAction),this._pendingAction=null}}class mg extends(Z()){constructor(e,t){super(),this.id=y(),this._filePromiseWrapper=this._createFilePromiseWrapper(e),this._adapter=t(this),this._reader=new pg,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((e,t)=>t?e/t*100:0)),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((e=>this._filePromiseWrapper?e:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new k("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((e=>this._reader.read(e))).then((e=>{if("reading"!==this.status)throw this.status;return this.status="idle",e})).catch((e=>{if("aborted"===e)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:e}))}upload(){if("idle"!=this.status)throw new k("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((e=>(this.uploadResponse=e,this.status="idle",e))).catch((e=>{if("aborted"===this.status)throw"aborted";throw this.status="error",e}))}abort(){const e=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==e?this._reader.abort():"uploading"==e&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch((()=>{})),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(e){const t={};return t.promise=new Promise(((n,r)=>{t.rejecter=r,t.isFulfilled=!1,e.then((e=>{t.isFulfilled=!0,n(e)})).catch((e=>{t.isFulfilled=!0,r(e)}))})),t}}class gg extends Jr{constructor(e){super(e),this.buttonView=new ji(e),this._fileInputView=new bg(e),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 bg extends Jr{constructor(e){super(e),this.set("acceptedType",void 0),this.set("allowMultipleFiles",!1);const t=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:t.to("acceptedType"),multiple:t.to("allowMultipleFiles")},on:{change:t.to((()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""}))}})}open(){this.element.click()}}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const yg="ckCsrfToken",vg="abcdefghijklmnopqrstuvwxyz0123456789";class _g{constructor(e,t,n){this.loader=e,this.url=t,this.t=n}upload(){return this.loader.file.then((e=>new Promise(((t,n)=>{this._initRequest(),this._initListeners(t,n,e),this._sendRequest(e)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const e=this.xhr=new XMLHttpRequest;e.open("POST",this.url,!0),e.responseType="json"}_initListeners(e,t,n){const r=this.xhr,i=this.loader,o=(0,this.t)("Cannot upload file:")+` ${n.name}.`;r.addEventListener("error",(()=>t(o))),r.addEventListener("abort",(()=>t())),r.addEventListener("load",(()=>{const n=r.response;if(!n||!n.uploaded)return t(n&&n.error&&n.error.message?n.error.message:o);e({default:n.url})})),r.upload&&r.upload.addEventListener("progress",(e=>{e.lengthComputable&&(i.uploadTotal=e.total,i.uploaded=e.loaded)}))}_sendRequest(e){const t=new FormData;t.append("upload",e),t.append("ckCsrfToken",function(){let e=function(e){e=e.toLowerCase();const t=document.cookie.split(";");for(const n of t){const t=n.split("=");if(decodeURIComponent(t[0].trim().toLowerCase())===e)return decodeURIComponent(t[1])}return null}(yg);var t,n;return e&&40==e.length||(e=function(e){let t="";const n=new Uint8Array(40);window.crypto.getRandomValues(n);for(let e=0;e.5?r.toUpperCase():r}return t}(),t=yg,n=e,document.cookie=encodeURIComponent(t)+"="+encodeURIComponent(n)+";path=/"),e}()),this.xhr.send(t)}}function wg(e,t,n,r){let i,o=null;"function"==typeof r?i=r:(o=e.commands.get(r),i=()=>{e.execute(r)}),e.model.document.on("change:data",((s,a)=>{if(o&&!o.isEnabled||!t.isEnabled)return;const l=Br(e.model.document.selection.getRanges());if(!l.isCollapsed)return;if(a.isUndo||!a.isLocal)return;const c=Array.from(e.model.document.differ.getChanges()),u=c[0];if(1!=c.length||"insert"!==u.type||"$text"!=u.name||1!=u.length)return;const d=u.position.parent;if(d.is("element","codeBlock"))return;if(d.is("element","listItem")&&"function"!=typeof r&&!["numberedList","bulletedList","todoList"].includes(r))return;if(o&&!0===o.value)return;const h=d.getChild(0),p=e.model.createRangeOn(h);if(!p.containsRange(l)&&!l.end.isEqual(p.end))return;const f=n.exec(h.data.substr(0,l.end.offset));f&&e.model.enqueueChange((t=>{const n=t.createPositionAt(d,0),r=t.createPositionAt(d,f[0].length),o=new Ul(n,r);if(!1!==i({match:f})){t.remove(o);const n=e.model.document.selection.getFirstRange(),r=t.createRangeIn(d);!d.isEmpty||r.isEqual(n)||r.containsRange(n,!0)||t.remove(d)}o.detach(),e.model.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}))}))}function kg(e,t,n,r){let i,o;n instanceof RegExp?i=n:o=n,o=o||(e=>{let t;const n=[],r=[];for(;null!==(t=i.exec(e))&&!(t&&t.length<4);){let{index:e,1:i,2:o,3:s}=t;const a=i+o+s;e+=t[0].length-a.length;const l=[e,e+i.length],c=[e+i.length+o.length,e+i.length+o.length+s.length];n.push(l),n.push(c),r.push([e+i.length,e+i.length+o.length])}return{remove:n,format:r}}),e.model.document.on("change:data",((n,i)=>{if(i.isUndo||!i.isLocal||!t.isEnabled)return;const s=e.model,a=s.document.selection;if(!a.isCollapsed)return;const l=Array.from(s.document.differ.getChanges()),c=l[0];if(1!=l.length||"insert"!==c.type||"$text"!=c.name||1!=c.length)return;const u=a.focus,d=u.parent,{text:h,range:p}=function(e,t){let n=e.start;return{text:Array.from(e.getItems()).reduce(((e,r)=>!r.is("$text")&&!r.is("$textProxy")||r.getAttribute("code")?(n=t.createPositionAfter(r),""):e+r.data),""),range:t.createRange(n,e.end)}}(s.createRange(s.createPositionAt(d,0),u),s),f=o(h),m=xg(p.start,f.format,s),g=xg(p.start,f.remove,s);m.length&&g.length&&s.enqueueChange((t=>{if(!1!==r(t,m)){for(const e of g.reverse())t.remove(e);s.enqueueChange((()=>{e.plugins.get("Delete").requestUndoOnBackspace()}))}}))}))}function xg(e,t,n){return t.filter((e=>void 0!==e[0]&&void 0!==e[1])).map((t=>n.createRange(e.getShiftedBy(t[0]),e.getShiftedBy(t[1]))))}function Cg(e,t){return(n,r)=>{if(!e.commands.get(t).isEnabled)return!1;const i=e.model.schema.getValidRanges(r,t);for(const e of i)n.setAttribute(t,!0,e);n.removeSelectionAttribute(t)}}class jg extends Gi{constructor(e,t){super(e),this.attributeKey=t}refresh(){const e=this.editor.model,t=e.document;this.value=this._getValueFromFirstAllowedNode(),this.isEnabled=e.schema.checkAttributeInSelection(t.selection,this.attributeKey)}execute(e={}){const t=this.editor.model,n=t.document.selection,r=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(n.isCollapsed)r?e.setSelectionAttribute(this.attributeKey,!0):e.removeSelectionAttribute(this.attributeKey);else{const i=t.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const t of i)r?e.setAttribute(this.attributeKey,r,t):e.removeAttribute(this.attributeKey,t)}}))}_getValueFromFirstAllowedNode(){const e=this.editor.model,t=e.schema,n=e.document.selection;if(n.isCollapsed)return n.hasAttribute(this.attributeKey);for(const e of n.getRanges())for(const n of e.getItems())if(t.checkAttribute(n,this.attributeKey))return n.hasAttribute(this.attributeKey);return!1}}const Ag="bold";class Sg extends qi{static get pluginName(){return"BoldEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Ag}),e.model.schema.setAttributeProperties(Ag,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Ag,view:"strong",upcastAlso:["b",e=>{const t=e.getStyle("font-weight");return t&&("bold"==t||Number(t)>=600)?{name:!0,styles:["font-weight"]}:null}]}),e.commands.add(Ag,new jg(e,Ag)),e.keystrokes.set("CTRL+B",Ag)}}const Mg="bold";class Ng extends qi{static get pluginName(){return"BoldUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(Mg,(n=>{const r=e.commands.get(Mg),i=new ji(n);return i.set({label:t("Bold"),icon:nh.bold,keystroke:"CTRL+B",tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(r,"value","isEnabled"),this.listenTo(i,"execute",(()=>{e.execute(Mg),e.editing.view.focus()})),i}))}}var Eg=o(8603);Kr()(Eg.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Eg.Z.locals;const Dg="italic";class Tg extends qi{static get pluginName(){return"ItalicEditing"}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:Dg}),e.model.schema.setAttributeProperties(Dg,{isFormatting:!0,copyOnEnter:!0}),e.conversion.attributeToElement({model:Dg,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),e.commands.add(Dg,new jg(e,Dg)),e.keystrokes.set("CTRL+I",Dg)}}const Og="italic";class Lg extends qi{static get pluginName(){return"ItalicUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add(Og,(n=>{const r=e.commands.get(Og),i=new ji(n);return i.set({label:t("Italic"),icon:'',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(r,"value","isEnabled"),this.listenTo(i,"execute",(()=>{e.execute(Og),e.editing.view.focus()})),i}))}}class Pg extends Gi{refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.schema,r=t.document.selection,i=Array.from(r.getSelectedBlocks()),o=void 0===e.forceValue?!this.value:e.forceValue;t.change((e=>{if(o){const t=i.filter((e=>Ig(e)||Rg(n,e)));this._applyQuote(e,t)}else this._removeQuote(e,i.filter(Ig))}))}_getValue(){const e=Br(this.editor.model.document.selection.getSelectedBlocks());return!(!e||!Ig(e))}_checkEnabled(){if(this.value)return!0;const e=this.editor.model.document.selection,t=this.editor.model.schema,n=Br(e.getSelectedBlocks());return!!n&&Rg(t,n)}_removeQuote(e,t){zg(e,t).reverse().forEach((t=>{if(t.start.isAtStart&&t.end.isAtEnd)return void e.unwrap(t.start.parent);if(t.start.isAtStart){const n=e.createPositionBefore(t.start.parent);return void e.move(t,n)}t.end.isAtEnd||e.split(t.end);const n=e.createPositionAfter(t.end.parent);e.move(t,n)}))}_applyQuote(e,t){const n=[];zg(e,t).reverse().forEach((t=>{let r=Ig(t.start);r||(r=e.createElement("blockQuote"),e.wrap(t,r)),n.push(r)})),n.reverse().reduce(((t,n)=>t.nextSibling==n?(e.merge(e.createPositionAfter(t)),t):n))}}function Ig(e){return"blockQuote"==e.parent.name?e.parent:null}function zg(e,t){let n,r=0;const i=[];for(;r{const r=e.model.document.differ.getChanges();for(const e of r)if("insert"==e.type){const r=e.position.nodeAfter;if(!r)continue;if(r.is("element","blockQuote")&&r.isEmpty)return n.remove(r),!0;if(r.is("element","blockQuote")&&!t.checkChild(e.position,r))return n.unwrap(r),!0;if(r.is("element")){const e=n.createRangeIn(r);for(const r of e.getItems())if(r.is("element","blockQuote")&&!t.checkChild(n.createPositionBefore(r),r))return n.unwrap(r),!0}}else if("remove"==e.type){const t=e.position.parent;if(t.is("element","blockQuote")&&t.isEmpty)return n.remove(t),!0}return!1}));const n=this.editor.editing.view.document,r=e.model.document.selection,i=e.commands.get("blockQuote");this.listenTo(n,"enter",((t,n)=>{r.isCollapsed&&i.value&&r.getLastPosition().parent.isEmpty&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{context:"blockquote"}),this.listenTo(n,"delete",((t,n)=>{if("backward"!=n.direction||!r.isCollapsed||!i.value)return;const o=r.getLastPosition().parent;o.isEmpty&&!o.previousSibling&&(e.execute("blockQuote"),e.editing.view.scrollToTheSelection(),n.preventDefault(),t.stop())}),{context:"blockquote"})}}var Fg=o(3062);Kr()(Fg.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Fg.Z.locals;class Yg extends qi{static get pluginName(){return"BlockQuoteUI"}init(){const e=this.editor,t=e.t;e.ui.componentFactory.add("blockQuote",(n=>{const r=e.commands.get("blockQuote"),i=new ji(n);return i.set({label:t("Block quote"),icon:nh.quote,tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(r,"value","isEnabled"),this.listenTo(i,"execute",(()=>{e.execute("blockQuote"),e.editing.view.focus()})),i}))}}class Hg extends qi{static get pluginName(){return"CKBoxUI"}afterInit(){const e=this.editor,t=e.commands.get("ckbox");if(!t)return;const n=e.t;e.ui.componentFactory.add("ckbox",(r=>{const i=new ji(r);return i.set({label:n("Open file manager"),icon:'',tooltip:!0}),i.bind("isOn","isEnabled").to(t,"value","isEnabled"),i.on("execute",(()=>{e.execute("ckbox")})),i}))}}const $g=4e3,Ug=80,Wg=10;function Vg({token:e,id:t,origin:n,width:r,extension:i}){const o=qg(e),s=function(e){const t=[e*Wg/100,Ug],n=Math.floor(Math.max(...t)),r=[Math.min(e,$g)];let i=r[0];for(;i-n>=n;)i-=n,r.unshift(i);return r}(r),a=function(e){return"bmp"===e||"tiff"===e||"jpg"===e?"jpeg":e}(i);return{imageFallbackUrl:Zg({environmentId:o,id:t,origin:n,width:r,extension:a}),imageSources:[{srcset:s.map((e=>`${Zg({environmentId:o,id:t,origin:n,width:e,extension:"webp"})} ${e}w`)).join(","),sizes:`(max-width: ${r}px) 100vw, ${r}px`,type:"image/webp"}]}}function qg(e){const[,t]=e.value.split(".");return JSON.parse(atob(t)).aud}function Zg({environmentId:e,id:t,origin:n,width:r,extension:i}){return new URL(`${e}/assets/${t}/images/${r}.${i}`,n).toString()}class Gg extends Gi{constructor(e){super(e),this._chosenAssets=new Set,this._wrapper=null,this._initListeners()}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(){this.fire("ckbox:open")}_getValue(){return null!==this._wrapper}_checkEnabled(){const e=this.editor.commands.get("insertImage"),t=this.editor.commands.get("link");return!(!e.isEnabled&&!t.isEnabled)}_prepareOptions(){const e=this.editor.config.get("ckbox");return{theme:e.theme,language:e.language,tokenUrl:e.tokenUrl,serviceOrigin:e.serviceOrigin,assetsOrigin:e.assetsOrigin,dialog:{onClose:()=>this.fire("ckbox:close")},assets:{onChoose:e=>this.fire("ckbox:choose",e)}}}_initListeners(){const e=this.editor,t=e.model,n=!e.config.get("ckbox.ignoreDataId");this.on("ckbox",(()=>{this.refresh()}),{priority:"low"}),this.on("ckbox:open",(()=>{this.isEnabled&&!this.value&&(this._wrapper=ye(document,"div",{class:"ck ckbox-wrapper"}),document.body.appendChild(this._wrapper),window.CKBox.mount(this._wrapper,this._prepareOptions()))})),this.on("ckbox:close",(()=>{this.value&&(this._wrapper.remove(),this._wrapper=null)})),this.on("ckbox:choose",((r,i)=>{if(!this.isEnabled)return;const o=e.commands.get("insertImage"),s=e.commands.get("link"),a=e.plugins.get("CKBoxEditing"),l=function({assets:e,origin:t,token:n,isImageAllowed:r,isLinkAllowed:i}){return e.map((e=>function(e){const t=e.data.metadata;return!!t&&t.width&&t.height}(e)?{id:e.data.id,type:"image",attributes:Kg(e,n,t)}:{id:e.data.id,type:"link",attributes:Qg(e,n,t)})).filter((e=>"image"===e.type?r:i))}({assets:i,origin:e.config.get("ckbox.assetsOrigin"),token:a.getToken(),isImageAllowed:o.isEnabled,isLinkAllowed:s.isEnabled});0!==l.length&&t.change((e=>{for(const t of l){const r=t===l[l.length-1];this._insertAsset(t,r,e),n&&(setTimeout((()=>this._chosenAssets.delete(t)),1e3),this._chosenAssets.add(t))}}))})),this.listenTo(e,"destroy",(()=>{this.fire("ckbox:close"),this._chosenAssets.clear()}))}_insertAsset(e,t,n){const r=this.editor.model.document.selection;n.removeSelectionAttribute("linkHref"),"image"===e.type?this._insertImage(e):this._insertLink(e,n),t||n.setSelection(r.getLastPosition())}_insertImage(e){const t=this.editor,{imageFallbackUrl:n,imageSources:r,imageTextAlternative:i}=e.attributes;t.execute("insertImage",{source:{src:n,sources:r,alt:i}})}_insertLink(e,t){const n=this.editor,r=n.model,i=r.document.selection,{linkName:o,linkHref:s}=e.attributes;if(i.isCollapsed){const e=Hr(i.getAttributes()),n=t.createText(o,e),s=r.insertContent(n);t.setSelection(s)}n.execute("link",s)}}function Kg(e,t,n){const{imageFallbackUrl:r,imageSources:i}=Vg({token:t,origin:n,id:e.data.id,width:e.data.metadata.width,extension:e.data.extension});return{imageFallbackUrl:r,imageSources:i,imageTextAlternative:e.data.metadata.description||""}}function Qg(e,t,n){return{linkName:e.data.name,linkHref:Jg(e,t,n)}}function Jg(e,t,n){const r=qg(t),i=new URL(`${r}/assets/${e.data.id}/file`,n);return i.searchParams.set("download","true"),i.toString()}var Xg=(e,t,n)=>new Promise(((r,i)=>{var o=e=>{try{a(n.next(e))}catch(e){i(e)}},s=e=>{try{a(n.throw(e))}catch(e){i(e)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,s);a((n=n.apply(e,t)).next())}));class eb extends qi{static get requires(){return["ImageUploadEditing","ImageUploadProgress",fg,rb]}static get pluginName(){return"CKBoxUploadAdapter"}afterInit(){return Xg(this,null,(function*(){const e=this.editor,t=!!e.config.get("ckbox"),n=!!window.CKBox;if(!t&&!n)return;const r=e.plugins.get(fg),i=e.plugins.get(rb);r.createUploadAdapter=t=>new tb(t,i.getToken(),e);const o=!e.config.get("ckbox.ignoreDataId"),s=e.plugins.get("ImageUploadEditing");o&&s.on("uploadComplete",((t,{imageElement:n,data:r})=>{e.model.change((e=>{e.setAttribute("ckboxImageId",r.ckboxImageId,n)}))}))}))}}class tb{constructor(e,t,n){this.loader=e,this.token=t,this.editor=n,this.controller=new AbortController,this.serviceOrigin=n.config.get("ckbox.serviceOrigin"),this.assetsOrigin=n.config.get("ckbox.assetsOrigin")}getAvailableCategories(e=0){return Xg(this,null,(function*(){const t=new URL("categories",this.serviceOrigin);return t.searchParams.set("limit",50..toString()),t.searchParams.set("offset",e.toString()),this._sendHttpRequest({url:t}).then((t=>Xg(this,null,(function*(){if(t.totalCount-(e+50)>0){const n=yield this.getAvailableCategories(e+50);return[...t.items,...n]}return t.items})))).catch((()=>{this.controller.signal.throwIfAborted(),C("ckbox-fetch-category-http-error")}))}))}getCategoryIdForFile(e){return Xg(this,null,(function*(){const t=nb(e.name),n=yield this.getAvailableCategories();if(!n)return null;const r=this.editor.config.get("ckbox.defaultUploadCategories");if(r){const e=Object.keys(r).find((e=>r[e].includes(t)));if(e){const t=n.find((t=>t.id===e||t.name===e));return t?t.id:null}}const i=n.find((e=>e.extensions.includes(t)));return i?i.id:null}))}upload(){return Xg(this,null,(function*(){const e=this.editor.t,t=e("Cannot determine a category for the uploaded file."),n=yield this.loader.file,r=yield this.getCategoryIdForFile(n);if(!r)return Promise.reject(t);const i=new URL("assets",this.serviceOrigin),o=new FormData;o.append("categoryId",r),o.append("file",n);const s={method:"POST",url:i,data:o,onUploadProgress:e=>{e.lengthComputable&&(this.loader.uploadTotal=e.total,this.loader.uploaded=e.loaded)}};return this._sendHttpRequest(s).then((e=>Xg(this,null,(function*(){const t=yield this._getImageWidth(),r=nb(n.name),i=Vg({token:this.token,id:e.id,origin:this.assetsOrigin,width:t,extension:r});return{ckboxImageId:e.id,default:i.imageFallbackUrl,sources:i.imageSources}})))).catch((()=>{const t=e("Cannot upload file:")+` ${n.name}.`;return Promise.reject(t)}))}))}abort(){this.controller.abort()}_sendHttpRequest({url:e,method:t="GET",data:n,onUploadProgress:r}){const i=this.controller.signal,o=new XMLHttpRequest;o.open(t,e.toString(),!0),o.setRequestHeader("Authorization",this.token.value),o.setRequestHeader("CKBox-Version","CKEditor 5"),o.responseType="json";const s=()=>{o.abort()};return new Promise(((e,t)=>{i.addEventListener("abort",s),o.addEventListener("loadstart",(()=>{i.addEventListener("abort",s)})),o.addEventListener("loadend",(()=>{i.removeEventListener("abort",s)})),o.addEventListener("error",(()=>{t()})),o.addEventListener("abort",(()=>{t()})),o.addEventListener("load",(()=>Xg(this,null,(function*(){const n=o.response;return!n||n.statusCode>=400?t(n&&n.message):e(n)})))),r&&o.upload.addEventListener("progress",(e=>{r(e)})),o.send(n)}))}_getImageWidth(){return new Promise((e=>{const t=new Image;t.onload=()=>{URL.revokeObjectURL(t.src),e(t.width)},t.src=this.loader.data}))}}function nb(e){const t=new RegExp("\\.(?[^.]+)$");return e.match(t).groups.ext}class rb extends qi{static get pluginName(){return"CKBoxEditing"}static get requires(){return["CloudServices","LinkEditing","PictureEditing",eb]}init(){return e=this,t=function*(){const e=this.editor,t=!!e.config.get("ckbox"),n=!!window.CKBox;if(!t&&!n)return;this._initConfig();const r=e.plugins.get("CloudServicesCore"),i=e.config.get("ckbox.tokenUrl");if(i===e.config.get("cloudServices.tokenUrl")){const t=e.plugins.get("CloudServices");this._token=t.token}else this._token=yield r.createToken(i).init();e.config.get("ckbox.ignoreDataId")||(this._initSchema(),this._initConversion(),this._initFixers()),n&&e.commands.add("ckbox",new Gg(e))},new Promise(((n,r)=>{var i=e=>{try{s(t.next(e))}catch(e){r(e)}},o=e=>{try{s(t.throw(e))}catch(e){r(e)}},s=e=>e.done?n(e.value):Promise.resolve(e.value).then(i,o);s((t=t.apply(e,null)).next())}));var e,t}getToken(){return this._token}_initConfig(){const e=this.editor;if(e.config.define("ckbox",{serviceOrigin:"https://api.ckbox.io",assetsOrigin:"https://ckbox.cloud",defaultUploadCategories:null,ignoreDataId:!1,language:e.locale.uiLanguage,theme:"default",tokenUrl:e.config.get("cloudServices.tokenUrl")}),!e.config.get("ckbox.tokenUrl"))throw new k("ckbox-plugin-missing-token-url",this);e.plugins.has("ImageBlockEditing")||e.plugins.has("ImageInlineEditing")||C("ckbox-plugin-image-feature-missing",e)}_initSchema(){const e=this.editor.model.schema;e.extend("$text",{allowAttributes:"ckboxLinkId"}),e.isRegistered("imageBlock")&&e.extend("imageBlock",{allowAttributes:["ckboxImageId","ckboxLinkId"]}),e.isRegistered("imageInline")&&e.extend("imageInline",{allowAttributes:["ckboxImageId","ckboxLinkId"]}),e.addAttributeCheck(((e,t)=>{if(!e.last.getAttribute("linkHref")&&"ckboxLinkId"===t)return!1}))}_initConversion(){const e=this.editor;e.conversion.for("downcast").add((e=>{e.on("attribute:ckboxLinkId:imageBlock",((e,t,n)=>{const{writer:r,mapper:i,consumable:o}=n;if(!o.consume(t.item,e.name))return;const s=[...i.toViewElement(t.item).getChildren()].find((e=>"a"===e.name));s&&(t.item.hasAttribute("ckboxLinkId")?r.setAttribute("data-ckbox-resource-id",t.item.getAttribute("ckboxLinkId"),s):r.removeAttribute("data-ckbox-resource-id",s))}),{priority:"low"}),e.on("attribute:ckboxLinkId",((e,t,n)=>{const{writer:r,mapper:i,consumable:o}=n;if(o.consume(t.item,e.name)){if(t.attributeOldValue){const e=ob(r,t.attributeOldValue);r.unwrap(i.toViewRange(t.range),e)}if(t.attributeNewValue){const e=ob(r,t.attributeNewValue);if(t.item.is("selection")){const t=r.document.selection;r.wrap(t.getFirstRange(),e)}else r.wrap(i.toViewRange(t.range),e)}}}),{priority:"low"})})),e.conversion.for("upcast").add((e=>{e.on("element:a",((e,t,n)=>{const{writer:r,consumable:i}=n;if(!t.viewItem.getAttribute("href"))return;if(!i.consume(t.viewItem,{attributes:["data-ckbox-resource-id"]}))return;const o=t.viewItem.getAttribute("data-ckbox-resource-id");if(o)if(t.modelRange)for(let e of t.modelRange.getItems())e.is("$textProxy")&&(e=e.textNode),sb(e)&&r.setAttribute("ckboxLinkId",o,e);else{const e=t.modelCursor.nodeBefore||t.modelCursor.parent;r.setAttribute("ckboxLinkId",o,e)}}),{priority:"low"})})),e.conversion.for("downcast").attributeToAttribute({model:"ckboxImageId",view:"data-ckbox-resource-id"}),e.conversion.for("upcast").elementToAttribute({model:{key:"ckboxImageId",value:e=>e.getAttribute("data-ckbox-resource-id")},view:{attributes:{"data-ckbox-resource-id":/[\s\S]+/}}})}_initFixers(){const e=this.editor,t=e.model,n=t.document.selection;t.document.registerPostFixer(function(e){return t=>{let n=!1;const r=e.model,i=e.commands.get("ckbox");if(!i)return n;for(const e of r.document.differ.getChanges()){if("insert"!==e.type&&"attribute"!==e.type)continue;const r="insert"===e.type?new wl(e.position,e.position.getShiftedBy(e.length)):e.range,o="attribute"===e.type&&"linkHref"===e.attributeKey&&null===e.attributeNewValue;for(const e of r.getItems()){if(o&&e.hasAttribute("ckboxLinkId")){t.removeAttribute("ckboxLinkId",e),n=!0;continue}const r=ib(e,i._chosenAssets);for(const i of r){const r="image"===i.type?"ckboxImageId":"ckboxLinkId";i.id!==e.getAttribute(r)&&(t.setAttribute(r,i.id,e),n=!0)}}}return n}}(e)),t.document.registerPostFixer(function(e){return t=>!(e.hasAttribute("linkHref")||!e.hasAttribute("ckboxLinkId")||(t.removeSelectionAttribute("ckboxLinkId"),0))}(n))}}function ib(e,t){const n=e.is("element","imageInline")||e.is("element","imageBlock"),r=e.hasAttribute("linkHref");return[...t].filter((t=>"image"===t.type&&n?t.attributes.imageFallbackUrl===e.getAttribute("src"):"link"===t.type&&r?t.attributes.linkHref===e.getAttribute("linkHref"):void 0))}function ob(e,t){const n=e.createAttributeElement("a",{"data-ckbox-resource-id":t},{priority:5});return e.setCustomProperty("link",!0,n),n}function sb(e){return!!e.is("$text")||!(!e.is("element","imageInline")&&!e.is("element","imageBlock"))}class ab extends qi{static get pluginName(){return"CKFinderUI"}init(){const e=this.editor,t=e.ui.componentFactory,n=e.t;t.add("ckfinder",(t=>{const r=e.commands.get("ckfinder"),i=new ji(t);return i.set({label:n("Insert image or file"),icon:'',tooltip:!0}),i.bind("isEnabled").to(r),i.on("execute",(()=>{e.execute("ckfinder"),e.editing.view.focus()})),i}))}}class lb extends Gi{constructor(e){super(e),this.affectsData=!1,this.stopListening(this.editor.model.document,"change"),this.listenTo(this.editor.model.document,"change",(()=>this.refresh()),{priority:"low"})}refresh(){const e=this.editor.commands.get("insertImage"),t=this.editor.commands.get("link");this.isEnabled=e.isEnabled||t.isEnabled}execute(){const e=this.editor,t=this.editor.config.get("ckfinder.openerMethod")||"modal";if("popup"!=t&&"modal"!=t)throw new k("ckfinder-unknown-openermethod",e);const n=this.editor.config.get("ckfinder.options")||{};n.chooseFiles=!0;const r=n.onInit;n.language||(n.language=e.locale.uiLanguage),n.onInit=t=>{r&&r(t),t.on("files:choose",(n=>{const r=n.data.files.toArray(),i=r.filter((e=>!e.isImage())),o=r.filter((e=>e.isImage()));for(const t of i)e.execute("link",t.getUrl());const s=[];for(const e of o){const n=e.getUrl();s.push(n||t.request("file:getProxyUrl",{file:e}))}s.length&&cb(e,s)})),t.on("file:choose:resizedImage",(t=>{const n=t.data.resizedUrl;if(n)cb(e,[n]);else{const t=e.plugins.get("Notification"),n=e.locale.t;t.showWarning(n("Could not obtain resized image URL."),{title:n("Selecting resized image failed"),namespace:"ckfinder"})}}))},window.CKFinder[t](n)}}function cb(e,t){if(e.commands.get("insertImage").isEnabled)e.execute("insertImage",{source:t});else{const t=e.plugins.get("Notification"),n=e.locale.t;t.showWarning(n("Could not insert image at the current position."),{title:n("Inserting image failed"),namespace:"ckfinder"})}}class ub extends qi{static get pluginName(){return"CKFinderEditing"}static get requires(){return[Yp,"LinkEditing"]}init(){const e=this.editor;if(!e.plugins.has("ImageBlockEditing")&&!e.plugins.has("ImageInlineEditing"))throw new k("ckfinder-missing-image-plugin",e);e.commands.add("ckfinder",new lb(e))}}class db extends qi{static get pluginName(){return"CloudServicesUploadAdapter"}static get requires(){return["CloudServices",fg]}init(){const e=this.editor,t=e.plugins.get("CloudServices"),n=t.token,r=t.uploadUrl;if(!n)return;const i=e.plugins.get("CloudServicesCore");this._uploadGateway=i.createUploadGateway(n,r),e.plugins.get(fg).createUploadAdapter=e=>new hb(this._uploadGateway,e)}}class hb{constructor(e,t){this.uploadGateway=e,this.loader=t}upload(){return this.loader.file.then((e=>(this.fileUploader=this.uploadGateway.upload(e),this.fileUploader.on("progress",((e,t)=>{this.loader.uploadTotal=t.total,this.loader.uploaded=t.uploaded})),this.fileUploader.send())))}abort(){this.fileUploader.abort()}}class pb extends Gi{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}refresh(){const e=this.editor.model,t=Br(e.document.selection.getSelectedBlocks());this.value=!!t&&t.is("element","paragraph"),this.isEnabled=!!t&&fb(t,e.schema)}execute(e={}){const t=this.editor.model,n=t.document,r=e.selection||n.selection;t.canEditAt(r)&&t.change((e=>{const n=r.getSelectedBlocks();for(const r of n)!r.is("element","paragraph")&&fb(r,t.schema)&&e.rename(r,"paragraph")}))}}function fb(e,t){return t.checkChild(e.parent,"paragraph")&&!t.isObject(e)}class mb extends Gi{constructor(e){super(e),this._isEnabledBasedOnSelection=!1}execute(e){const t=this.editor.model,n=e.attributes;let r=e.position;t.canEditAt(r)&&t.change((e=>{const i=e.createElement("paragraph");if(n&&t.schema.setAllowedAttributes(i,n,e),!t.schema.checkChild(r.parent,i)){const n=t.schema.findAllowedParent(r,i);if(!n)return;r=e.split(r,n).position}t.insertContent(i,r),e.setSelection(i,"in")}))}}const gb=class extends qi{static get pluginName(){return"Paragraph"}init(){const e=this.editor,t=e.model;e.commands.add("paragraph",new pb(e)),e.commands.add("insertParagraph",new mb(e)),t.schema.register("paragraph",{inheritAllFrom:"$block"}),e.conversion.elementToElement({model:"paragraph",view:"p"}),e.conversion.for("upcast").elementToElement({model:(e,{writer:t})=>gb.paragraphLikeElements.has(e.name)?e.isEmpty?null:t.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}};let bb=gb;bb.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class yb extends Gi{constructor(e,t){super(e),this.modelElements=t}refresh(){const e=Br(this.editor.model.document.selection.getSelectedBlocks());this.value=!!e&&this.modelElements.includes(e.name)&&e.name,this.isEnabled=!!e&&this.modelElements.some((t=>vb(e,t,this.editor.model.schema)))}execute(e){const t=this.editor.model,n=t.document,r=e.value;t.change((e=>{const i=Array.from(n.selection.getSelectedBlocks()).filter((e=>vb(e,r,t.schema)));for(const t of i)t.is("element",r)||e.rename(t,r)}))}}function vb(e,t,n){return n.checkChild(e.parent,t)&&!n.isObject(e)}const _b="paragraph";class wb extends qi{static get pluginName(){return"HeadingEditing"}constructor(e){super(e),e.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[bb]}init(){const e=this.editor,t=e.config.get("heading.options"),n=[];for(const r of t)"paragraph"!==r.model&&(e.model.schema.register(r.model,{inheritAllFrom:"$block"}),e.conversion.elementToElement(r),n.push(r.model));this._addDefaultH1Conversion(e),e.commands.add("heading",new yb(e,n))}afterInit(){const e=this.editor,t=e.commands.get("enter"),n=e.config.get("heading.options");t&&this.listenTo(t,"afterExecute",((t,r)=>{const i=e.model.document.selection.getFirstPosition().parent;n.some((e=>i.is("element",e.model)))&&!i.is("element",_b)&&0===i.childCount&&r.writer.rename(i,_b)}))}_addDefaultH1Conversion(e){e.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:v.low+1})}}var kb=o(8733);Kr()(kb.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),kb.Z.locals;class xb extends qi{static get pluginName(){return"HeadingUI"}init(){const e=this.editor,t=e.t,n=function(e){const t=e.t,n={Paragraph:t("Paragraph"),"Heading 1":t("Heading 1"),"Heading 2":t("Heading 2"),"Heading 3":t("Heading 3"),"Heading 4":t("Heading 4"),"Heading 5":t("Heading 5"),"Heading 6":t("Heading 6")};return e.config.get("heading.options").map((e=>{const t=n[e.title];return t&&t!=e.title&&(e.title=t),e}))}(e),r=t("Choose heading"),i=t("Heading");e.ui.componentFactory.add("heading",(t=>{const o={},s=new Rr,a=e.commands.get("heading"),l=e.commands.get("paragraph"),c=[a];for(const e of n){const t={type:"button",model:new Hp({label:e.title,class:e.class,role:"menuitemradio",withText:!0})};"paragraph"===e.model?(t.model.bind("isOn").to(l,"value"),t.model.set("commandName","paragraph"),c.push(l)):(t.model.bind("isOn").to(a,"value",(t=>t===e.model)),t.model.set({commandName:"heading",commandValue:e.model})),s.add(t),o[e.model]=e.title}const u=yh(t);return wh(u,s,{ariaLabel:i,role:"menu"}),u.buttonView.set({ariaLabel:i,ariaLabelledBy:void 0,isOn:!1,withText:!0,tooltip:i}),u.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),u.bind("isEnabled").toMany(c,"isEnabled",((...e)=>e.some((e=>e)))),u.buttonView.bind("label").to(a,"value",l,"value",((e,t)=>{const n=e||t&&"paragraph";return"boolean"==typeof n?r:o[n]?o[n]:r})),this.listenTo(u,"execute",(t=>{const{commandName:n,commandValue:r}=t.source;e.execute(n,r?{value:r}:void 0),e.editing.view.focus()})),u}))}}function Cb(e){return e.createContainerElement("figure",{class:"image"},[e.createEmptyElement("img"),e.createSlot("children")])}function jb(e,t){const n=e.plugins.get("ImageUtils"),r=e.plugins.has("ImageInlineEditing")&&e.plugins.has("ImageBlockEditing");return e=>n.isInlineImageView(e)?r&&("block"==e.getStyle("display")||e.findAncestor(n.isBlockImageView)?"imageBlock":"imageInline")!==t?null:i(e):null;function i(e){const t={name:!0};return e.hasAttribute("src")&&(t.attributes=["src"]),t}}function Ab(e,t){const n=Br(t.getSelectedBlocks());return!n||e.isObject(n)||n.isEmpty&&"listItem"!=n.name?"imageBlock":"imageInline"}var Sb=Object.defineProperty,Mb=Object.getOwnPropertySymbols,Nb=Object.prototype.hasOwnProperty,Eb=Object.prototype.propertyIsEnumerable,Db=(e,t,n)=>t in e?Sb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tb=(e,t)=>{for(var n in t||(t={}))Nb.call(t,n)&&Db(e,n,t[n]);if(Mb)for(var n of Mb(t))Eb.call(t,n)&&Db(e,n,t[n]);return e};class Ob extends qi{static get pluginName(){return"ImageUtils"}isImage(e){return this.isInlineImage(e)||this.isBlockImage(e)}isInlineImageView(e){return!!e&&e.is("element","img")}isBlockImageView(e){return!!e&&e.is("element","figure")&&e.hasClass("image")}insertImage(e={},t=null,n=null){const r=this.editor,i=r.model,o=i.document.selection;n=Lb(r,t||o,n),e=Tb(Tb({},Object.fromEntries(o.getAttributes())),e);for(const t in e)i.schema.checkAttribute(n,t)||delete e[t];return i.change((r=>{const o=r.createElement(n,e);return i.insertObject(o,t,null,{setSelection:"on",findOptimalPosition:t||"imageInline"==n?void 0:"auto"}),o.parent?o:null}))}getClosestSelectedImageWidget(e){const t=e.getFirstPosition();if(!t)return null;const n=e.getSelectedElement();if(n&&this.isImageWidget(n))return n;let r=t.parent;for(;r;){if(r.is("element")&&this.isImageWidget(r))return r;r=r.parent}return null}getClosestSelectedImageElement(e){const t=e.getSelectedElement();return this.isImage(t)?t:e.getFirstPosition().findAncestor("imageBlock")}isImageAllowed(){const e=this.editor.model.document.selection;return function(e,t){if("imageBlock"==Lb(e,t,null)){const n=function(e,t){const n=_m(e,t).start.parent;return n.isEmpty&&!n.is("element","$root")?n.parent:n}(t,e.model);if(e.model.schema.checkChild(n,"imageBlock"))return!0}else if(e.model.schema.checkChild(t.focus,"imageInline"))return!0;return!1}(this.editor,e)&&function(e){return[...e.focus.getAncestors()].every((e=>!e.is("element","imageBlock")))}(e)}toImageWidget(e,t,n){return t.setCustomProperty("image",!0,e),mm(e,t,{label:()=>{const t=this.findViewImgElement(e).getAttribute("alt");return t?`${t} ${n}`:n}})}isImageWidget(e){return!!e.getCustomProperty("image")&&fm(e)}isBlockImage(e){return!!e&&e.is("element","imageBlock")}isInlineImage(e){return!!e&&e.is("element","imageInline")}findViewImgElement(e){if(this.isInlineImageView(e))return e;const t=this.editor.editing.view;for(const{item:n}of t.createRangeIn(e))if(this.isInlineImageView(n))return n}}function Lb(e,t,n){const r=e.model.schema,i=e.config.get("image.insert.type");return e.plugins.has("ImageBlockEditing")?e.plugins.has("ImageInlineEditing")?n||("inline"===i?"imageInline":"block"===i?"imageBlock":t.is("selection")?Ab(r,t):r.checkChild(t,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable,new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@!$&'()*+,;=%-]+/.source+/\.(jpg|jpeg|png|gif|ico|webp|JPG|JPEG|PNG|GIF|ICO|WEBP)/.source+/(\?[\w.~:/[\]@!$&'()*+,;=%-]*)?/.source+/(#[\w.~:/[\]@!$&'()*+,;=%-]*)?$/.source));class Pb extends Gi{refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled&&e.hasAttribute("alt")?this.value=e.getAttribute("alt"):this.value=!1}execute(e){const t=this.editor,n=t.plugins.get("ImageUtils"),r=t.model,i=n.getClosestSelectedImageElement(r.document.selection);r.change((t=>{t.setAttribute("alt",e.newValue,i)}))}}class Ib extends qi{static get requires(){return[Ob]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new Pb(this.editor))}}var zb=o(1905);Kr()(zb.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),zb.Z.locals;var Rb=o(6764);Kr()(Rb.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Rb.Z.locals;class Bb extends Jr{constructor(e){super(e);const t=this.locale.t;this.focusTracker=new Fr,this.keystrokes=new Yr,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(t("Save"),nh.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(t("Cancel"),nh.cancel,"ck-button-cancel","cancel"),this._focusables=new Zr,this._focusCycler=new Hi({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","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),this.keystrokes.listenTo(this.element),a({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(e,t,n,r){const i=new ji(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),r&&i.delegate("execute").to(this,r),i}_createLabeledInputView(){const e=this.locale.t,t=new Ti(this.locale,Ch);return t.label=e("Text alternative"),t}}function Fb(e){const t=e.editing.view,n=cp.defaultPositions,r=e.plugins.get("ImageUtils");return{target:t.domConverter.mapViewToDom(r.getClosestSelectedImageWidget(t.document.selection)),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class Yb extends qi{static get requires(){return[Vp]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton()}destroy(){super.destroy(),this._form&&this._form.destroy()}_createButton(){const e=this.editor,t=e.t;e.ui.componentFactory.add("imageTextAlternative",(n=>{const r=e.commands.get("imageTextAlternative"),i=new ji(n);return i.set({label:t("Change image text alternative"),icon:nh.lowVision,tooltip:!0}),i.bind("isEnabled").to(r,"isEnabled"),i.bind("isOn").to(r,"value",(e=>!!e)),this.listenTo(i,"execute",(()=>{this._showForm()})),i}))}_createForm(){const e=this.editor,t=e.editing.view.document,n=e.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new(i(Bb))(e.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{e.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((e,t)=>{this._hideForm(!0),t()})),this.listenTo(e.ui,"update",(()=>{n.getClosestSelectedImageWidget(t.selection)?this._isVisible&&function(e){const t=e.plugins.get("ContextualBalloon");if(e.plugins.get("ImageUtils").getClosestSelectedImageWidget(e.editing.view.document.selection)){const n=Fb(e);t.updatePosition(n)}}(e):this._hideForm(!0)})),r({emitter:this._form,activator:()=>this._isVisible,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;this._form||this._createForm();const e=this.editor,t=e.commands.get("imageTextAlternative"),n=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:Fb(e)}),n.fieldView.value=n.fieldView.element.value=t.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(e=!1){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),e&&this.editor.editing.view.focus())}get _isVisible(){return!!this._balloon&&this._balloon.visibleView===this._form}get _isInBalloon(){return!!this._balloon&&this._balloon.hasView(this._form)}}class Hb extends qi{static get requires(){return[Ib,Yb]}static get pluginName(){return"ImageTextAlternative"}}function $b(e,t){const n=(t,n,r)=>{if(!r.consumable.consume(n.item,t.name))return;const i=r.writer,o=r.mapper.toViewElement(n.item),s=e.findViewImgElement(o);if(null===n.attributeNewValue){const e=n.attributeOldValue;e&&e.data&&(i.removeAttribute("srcset",s),i.removeAttribute("sizes",s),e.width&&i.removeAttribute("width",s))}else{const e=n.attributeNewValue;e&&e.data&&(i.setAttribute("srcset",e.data,s),i.setAttribute("sizes","100vw",s),e.width&&i.setAttribute("width",e.width,s))}};return e=>{e.on(`attribute:srcset:${t}`,n)}}function Ub(e,t,n){const r=(t,n,r)=>{if(!r.consumable.consume(n.item,t.name))return;const i=r.writer,o=r.mapper.toViewElement(n.item),s=e.findViewImgElement(o);i.setAttribute(n.attributeKey,n.attributeNewValue||"",s)};return e=>{e.on(`attribute:${n}:${t}`,r)}}class Wb extends fa{observe(e){this.listenTo(e,"load",((e,t)=>{const n=t.target;this.checkShouldIgnoreEventFromTarget(n)||"IMG"==n.tagName&&this._fireEvents(t)}),{useCapture:!0})}stopObserving(e){this.stopListening(e)}_fireEvents(e){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",e))}}var Vb=Object.defineProperty,qb=Object.getOwnPropertySymbols,Zb=Object.prototype.hasOwnProperty,Gb=Object.prototype.propertyIsEnumerable,Kb=(e,t,n)=>t in e?Vb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Qb=(e,t)=>{for(var n in t||(t={}))Zb.call(t,n)&&Kb(e,n,t[n]);if(qb)for(var n of qb(t))Gb.call(t,n)&&Kb(e,n,t[n]);return e};class Jb extends Gi{constructor(e){super(e);const t=e.config.get("image.insert.type");e.plugins.has("ImageBlockEditing")||"block"===t&&x("image-block-plugin-required"),e.plugins.has("ImageInlineEditing")||"inline"===t&&x("image-inline-plugin-required")}refresh(){const e=this.editor.plugins.get("ImageUtils");this.isEnabled=e.isImageAllowed()}execute(e){const t=Lr(e.source),n=this.editor.model.document.selection,r=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());t.forEach(((e,t)=>{const o=n.getSelectedElement();if("string"==typeof e&&(e={src:e}),t&&o&&r.isImage(o)){const t=this.editor.model.createPositionAfter(o);r.insertImage(Qb(Qb({},e),i),t)}else r.insertImage(Qb(Qb({},e),i))}))}}class Xb extends Gi{refresh(){const e=this.editor.plugins.get("ImageUtils"),t=this.editor.model.document.selection.getSelectedElement();this.isEnabled=e.isImage(t),this.value=this.isEnabled?t.getAttribute("src"):null}execute(e){const t=this.editor.model.document.selection.getSelectedElement();this.editor.model.change((n=>{n.setAttribute("src",e.source,t),n.removeAttribute("srcset",t),n.removeAttribute("sizes",t)}))}}class ey extends qi{static get requires(){return[Ob]}static get pluginName(){return"ImageEditing"}init(){const e=this.editor,t=e.conversion;e.editing.view.addObserver(Wb),t.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:e=>{const t={data:e.getAttribute("srcset")};return e.hasAttribute("width")&&(t.width=e.getAttribute("width")),t}}});const n=new Jb(e),r=new Xb(e);e.commands.add("insertImage",n),e.commands.add("replaceImageSource",r),e.commands.add("imageInsert",n)}}class ty extends Gi{constructor(e,t){super(e),this._modelElementName=t}refresh(){const e=this.editor.plugins.get("ImageUtils"),t=e.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=e.isInlineImage(t):this.isEnabled=e.isBlockImage(t)}execute(){const e=this.editor,t=this.editor.model,n=e.plugins.get("ImageUtils"),r=n.getClosestSelectedImageElement(t.document.selection),i=Object.fromEntries(r.getAttributes());return i.src||i.uploadId?t.change((e=>{const o=Array.from(t.markers).filter((e=>e.getRange().containsItem(r))),s=n.insertImage(i,t.createSelection(r,"on"),this._modelElementName);if(!s)return null;const a=e.createRangeOn(s);for(const t of o){const n=t.getRange(),r="$graveyard"!=n.root.rootName?n.getJoined(a,!0):a;e.updateMarker(t,{range:r})}return{oldElement:r,newElement:s}})):null}}class ny extends qi{static get requires(){return[ey,Ob,bf]}static get pluginName(){return"ImageBlockEditing"}init(){const e=this.editor;e.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),e.plugins.has("ImageInlineEditing")&&(e.commands.add("imageTypeBlock",new ty(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,n=e.conversion,r=e.plugins.get("ImageUtils");n.for("dataDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:t})=>Cb(t)}),n.for("editingDowncast").elementToStructure({model:"imageBlock",view:(e,{writer:n})=>r.toImageWidget(Cb(n),n,t("image widget"))}),n.for("downcast").add(Ub(r,"imageBlock","src")).add(Ub(r,"imageBlock","alt")).add($b(r,"imageBlock")),n.for("upcast").elementToElement({view:jb(e,"imageBlock"),model:(e,{writer:t})=>t.createElement("imageBlock",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)}).add(function(e){const t=(t,n,r)=>{if(!r.consumable.test(n.viewItem,{name:!0,classes:"image"}))return;const i=e.findViewImgElement(n.viewItem);if(!i||!r.consumable.test(i,{name:!0}))return;r.consumable.consume(n.viewItem,{name:!0,classes:"image"});const o=Br(r.convertItem(i,n.modelCursor).modelRange.getItems());o?(r.convertChildren(n.viewItem,o),r.updateConversionResult(o,n)):r.consumable.revert(n.viewItem,{name:!0,classes:"image"})};return e=>{e.on("element:figure",t)}}(r))}_setupClipboardIntegration(){const e=this.editor,t=e.model,n=e.editing.view,r=e.plugins.get("ImageUtils"),i=e.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",((i,o)=>{const s=Array.from(o.content.getChildren());let a;if(!s.every(r.isInlineImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageBlock"===Ab(t.schema,l)){const e=new Kd(n.document),t=s.map((t=>e.createElement("figure",{class:"image"},t)));o.content=e.createDocumentFragment(t)}}))}}var ry=o(3508);Kr()(ry.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),ry.Z.locals;class iy extends qi{static get requires(){return[ny,Om,Hb]}static get pluginName(){return"ImageBlock"}}class oy extends qi{static get requires(){return[ey,Ob,bf]}static get pluginName(){return"ImageInlineEditing"}init(){const e=this.editor,t=e.model.schema;t.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]}),t.addChildCheck(((e,t)=>{if(e.endsWith("caption")&&"imageInline"===t.name)return!1})),this._setupConversion(),e.plugins.has("ImageBlockEditing")&&(e.commands.add("imageTypeInline",new ty(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const e=this.editor,t=e.t,n=e.conversion,r=e.plugins.get("ImageUtils");n.for("dataDowncast").elementToElement({model:"imageInline",view:(e,{writer:t})=>t.createEmptyElement("img")}),n.for("editingDowncast").elementToStructure({model:"imageInline",view:(e,{writer:n})=>r.toImageWidget(function(e){return e.createContainerElement("span",{class:"image-inline"},e.createEmptyElement("img"))}(n),n,t("image widget"))}),n.for("downcast").add(Ub(r,"imageInline","src")).add(Ub(r,"imageInline","alt")).add($b(r,"imageInline")),n.for("upcast").elementToElement({view:jb(e,"imageInline"),model:(e,{writer:t})=>t.createElement("imageInline",e.hasAttribute("src")?{src:e.getAttribute("src")}:void 0)})}_setupClipboardIntegration(){const e=this.editor,t=e.model,n=e.editing.view,r=e.plugins.get("ImageUtils"),i=e.plugins.get("ClipboardPipeline");this.listenTo(i,"inputTransformation",((i,o)=>{const s=Array.from(o.content.getChildren());let a;if(!s.every(r.isBlockImageView))return;a=o.targetRanges?e.editing.mapper.toModelRange(o.targetRanges[0]):t.document.selection.getFirstRange();const l=t.createSelection(a);if("imageInline"===Ab(t.schema,l)){const e=new Kd(n.document),t=s.map((t=>1===t.childCount?(Array.from(t.getAttributes()).forEach((n=>e.setAttribute(...n,r.findViewImgElement(t)))),t.getChild(0)):t));o.content=e.createDocumentFragment(t)}}))}}class sy extends qi{static get requires(){return[oy,Om,Hb]}static get pluginName(){return"ImageInline"}}class ay extends qi{static get pluginName(){return"ImageCaptionUtils"}static get requires(){return[Ob]}getCaptionFromImageModelElement(e){for(const t of e.getChildren())if(t&&t.is("element","caption"))return t;return null}getCaptionFromModelSelection(e){const t=this.editor.plugins.get("ImageUtils"),n=e.getFirstPosition().findAncestor("caption");return n&&t.isBlockImage(n.parent)?n:null}matchImageCaptionViewElement(e){const t=this.editor.plugins.get("ImageUtils");return"figcaption"==e.name&&t.isBlockImageView(e.parent)?{name:!0}:null}}class ly extends Gi{refresh(){const e=this.editor,t=e.plugins.get("ImageCaptionUtils"),n=e.plugins.get("ImageUtils");if(!e.plugins.has(ny))return this.isEnabled=!1,void(this.value=!1);const r=e.model.document.selection,i=r.getSelectedElement();if(!i){const e=t.getCaptionFromModelSelection(r);return this.isEnabled=!!e,void(this.value=!!e)}this.isEnabled=n.isImage(i),this.isEnabled?this.value=!!t.getCaptionFromImageModelElement(i):this.value=!1}execute(e={}){const{focusCaptionOnShow:t}=e;this.editor.model.change((e=>{this.value?this._hideImageCaption(e):this._showImageCaption(e,t)}))}_showImageCaption(e,t){const n=this.editor.model.document.selection,r=this.editor.plugins.get("ImageCaptionEditing"),i=this.editor.plugins.get("ImageUtils");let o=n.getSelectedElement();const s=r._getSavedCaption(o);i.isInlineImage(o)&&(this.editor.execute("imageTypeBlock"),o=n.getSelectedElement());const a=s||e.createElement("caption");e.append(a,o),t&&e.setSelection(a,"in")}_hideImageCaption(e){const t=this.editor,n=t.model.document.selection,r=t.plugins.get("ImageCaptionEditing"),i=t.plugins.get("ImageCaptionUtils");let o,s=n.getSelectedElement();s?o=i.getCaptionFromImageModelElement(s):(o=i.getCaptionFromModelSelection(n),s=o.parent),r._saveCaption(s,o),e.setSelection(s,"on"),e.remove(o)}}class cy extends qi{constructor(e){super(e),this._savedCaptionsMap=new WeakMap}static get requires(){return[Ob,ay]}static get pluginName(){return"ImageCaptionEditing"}init(){const e=this.editor,t=e.model.schema;t.isRegistered("caption")?t.extend("caption",{allowIn:"imageBlock"}):t.register("caption",{allowIn:"imageBlock",allowContentOf:"$block",isLimit:!0}),e.commands.add("toggleImageCaption",new ly(this.editor)),this._setupConversion(),this._setupImageTypeCommandsIntegration(),this._registerCaptionReconversion()}_setupConversion(){const e=this.editor,t=e.editing.view,n=e.plugins.get("ImageUtils"),r=e.plugins.get("ImageCaptionUtils"),i=e.t;e.conversion.for("upcast").elementToElement({view:e=>r.matchImageCaptionViewElement(e),model:"caption"}),e.conversion.for("dataDowncast").elementToElement({model:"caption",view:(e,{writer:t})=>n.isBlockImage(e.parent)?t.createContainerElement("figcaption"):null}),e.conversion.for("editingDowncast").elementToElement({model:"caption",view:(e,{writer:r})=>{if(!n.isBlockImage(e.parent))return null;const o=r.createEditableElement("figcaption");r.setCustomProperty("imageCaption",!0,o),io({view:t,element:o,text:i("Enter image caption"),keepOnFocus:!0});const s=e.parent.getAttribute("alt");return vm(o,r,{label:s?i("Caption for image: %0",[s]):i("Caption for the image")})}})}_setupImageTypeCommandsIntegration(){const e=this.editor,t=e.plugins.get("ImageUtils"),n=e.plugins.get("ImageCaptionUtils"),r=e.commands.get("imageTypeInline"),i=e.commands.get("imageTypeBlock"),o=e=>{if(!e.return)return;const{oldElement:r,newElement:i}=e.return;if(!r)return;if(t.isBlockImage(r)){const e=n.getCaptionFromImageModelElement(r);if(e)return void this._saveCaption(i,e)}const o=this._getSavedCaption(r);o&&this._saveCaption(i,o)};r&&this.listenTo(r,"execute",o,{priority:"low"}),i&&this.listenTo(i,"execute",o,{priority:"low"})}_getSavedCaption(e){const t=this._savedCaptionsMap.get(e);return t?hl.fromJSON(t):null}_saveCaption(e,t){this._savedCaptionsMap.set(e,t.toJSON())}_registerCaptionReconversion(){const e=this.editor,t=e.model,n=e.plugins.get("ImageUtils"),r=e.plugins.get("ImageCaptionUtils");t.document.on("change:data",(()=>{const i=t.document.differ.getChanges();for(const t of i){if("alt"!==t.attributeKey)continue;const i=t.range.start.nodeAfter;if(n.isBlockImage(i)){const t=r.getCaptionFromImageModelElement(i);if(!t)return;e.editing.reconvertItem(t)}}}))}}class uy extends qi{static get requires(){return[ay]}static get pluginName(){return"ImageCaptionUI"}init(){const e=this.editor,t=e.editing.view,n=e.plugins.get("ImageCaptionUtils"),r=e.t;e.ui.componentFactory.add("toggleImageCaption",(i=>{const o=e.commands.get("toggleImageCaption"),s=new ji(i);return s.set({icon:nh.caption,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),s.bind("label").to(o,"value",(e=>r(e?"Toggle caption off":"Toggle caption on"))),this.listenTo(s,"execute",(()=>{e.execute("toggleImageCaption",{focusCaptionOnShow:!0});const r=n.getCaptionFromModelSelection(e.model.document.selection);if(r){const n=e.editing.mapper.toViewElement(r);t.scrollToTheSelection(),t.change((e=>{e.addClass("image__caption_highlighted",n)}))}e.editing.view.focus()})),s}))}}var dy=o(2640);function hy(e){const t=e.map((e=>e.replace("+","\\+")));return new RegExp(`^image\\/(${t.join("|")})$`)}function py(e){return new Promise(((t,n)=>{const r=e.getAttribute("src");fetch(r).then((e=>e.blob())).then((e=>{const n=fy(e,r),i=n.replace("image/",""),o=new File([e],`image.${i}`,{type:n});t(o)})).catch((e=>e&&"TypeError"===e.name?function(e){return function(e){return new Promise(((t,n)=>{const r=Zn.document.createElement("img");r.addEventListener("load",(()=>{const e=Zn.document.createElement("canvas");e.width=r.width,e.height=r.height,e.getContext("2d").drawImage(r,0,0),e.toBlob((e=>e?t(e):n()))})),r.addEventListener("error",(()=>n())),r.src=e}))}(e).then((t=>{const n=fy(t,e),r=n.replace("image/","");return new File([t],`image.${r}`,{type:n})}))}(r).then(t).catch(n):n(e)))}))}function fy(e,t){return e.type?e.type:t.match(/data:(image\/\w+);base64/)?t.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}Kr()(dy.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),dy.Z.locals;class my extends qi{static get pluginName(){return"ImageUploadUI"}init(){const e=this.editor,t=e.t,n=n=>{const r=new gg(n),i=e.commands.get("uploadImage"),o=e.config.get("image.upload.types"),s=hy(o);return r.set({acceptedType:o.map((e=>`image/${e}`)).join(","),allowMultipleFiles:!0}),r.buttonView.set({label:t("Insert image"),icon:nh.image,tooltip:!0}),r.buttonView.bind("isEnabled").to(i),r.on("done",((t,n)=>{const r=Array.from(n).filter((e=>s.test(e.type)));r.length&&(e.execute("uploadImage",{file:r}),e.editing.view.focus())})),r};e.ui.componentFactory.add("uploadImage",n),e.ui.componentFactory.add("imageUpload",n)}}var gy=o(3689);Kr()(gy.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),gy.Z.locals;var by=o(4036);Kr()(by.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),by.Z.locals;var yy=o(3773);Kr()(yy.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),yy.Z.locals;class vy extends qi{constructor(e){super(e),this.uploadStatusChange=(e,t,n)=>{const r=this.editor,i=t.item,o=i.getAttribute("uploadId");if(!n.consumable.consume(t.item,e.name))return;const s=r.plugins.get("ImageUtils"),a=r.plugins.get(fg),l=o?t.attributeNewValue:null,c=this.placeholder,u=r.editing.mapper.toViewElement(i),d=n.writer;if("reading"==l)return _y(u,d),void wy(s,c,u,d);if("uploading"==l){const e=a.loaders.get(o);return _y(u,d),void(e?(ky(u,d),function(e,t,n,r){const i=function(e){const t=e.createUIElement("div",{class:"ck-progress-bar"});return e.setCustomProperty("progressBar",!0,t),t}(t);t.insert(t.createPositionAt(e,"end"),i),n.on("change:uploadedPercent",((e,t,n)=>{r.change((e=>{e.setStyle("width",n+"%",i)}))}))}(u,d,e,r.editing.view),function(e,t,n,r){if(r.data){const i=e.findViewImgElement(t);n.setAttribute("src",r.data,i)}}(s,u,d,e)):wy(s,c,u,d))}"complete"==l&&a.loaders.get(o)&&function(e,t,n){const r=t.createUIElement("div",{class:"ck-image-upload-complete-icon"});t.insert(t.createPositionAt(e,"end"),r),setTimeout((()=>{n.change((e=>e.remove(e.createRangeOn(r))))}),3e3)}(u,d,r.editing.view),function(e,t){Cy(e,t,"progressBar")}(u,d),ky(u,d),function(e,t){t.removeClass("ck-appear",e)}(u,d)},this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}static get pluginName(){return"ImageUploadProgress"}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",this.uploadStatusChange),e.plugins.has("ImageInlineEditing")&&e.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",this.uploadStatusChange)}}function _y(e,t){e.hasClass("ck-appear")||t.addClass("ck-appear",e)}function wy(e,t,n,r){n.hasClass("ck-image-upload-placeholder")||r.addClass("ck-image-upload-placeholder",n);const i=e.findViewImgElement(n);i.getAttribute("src")!==t&&r.setAttribute("src",t,i),xy(n,"placeholder")||r.insert(r.createPositionAfter(i),function(e){const t=e.createUIElement("div",{class:"ck-upload-placeholder-loader"});return e.setCustomProperty("placeholder",!0,t),t}(r))}function ky(e,t){e.hasClass("ck-image-upload-placeholder")&&t.removeClass("ck-image-upload-placeholder",e),Cy(e,t,"placeholder")}function xy(e,t){for(const n of e.getChildren())if(n.getCustomProperty(t))return n}function Cy(e,t,n){const r=xy(e,n);r&&t.remove(t.createRangeOn(r))}var jy=Object.defineProperty,Ay=Object.defineProperties,Sy=Object.getOwnPropertyDescriptors,My=Object.getOwnPropertySymbols,Ny=Object.prototype.hasOwnProperty,Ey=Object.prototype.propertyIsEnumerable,Dy=(e,t,n)=>t in e?jy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;class Ty extends Gi{refresh(){const e=this.editor,t=e.plugins.get("ImageUtils"),n=e.model.document.selection.getSelectedElement();this.isEnabled=t.isImageAllowed()||t.isImage(n)}execute(e){const t=Lr(e.file),n=this.editor.model.document.selection,r=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());t.forEach(((e,t)=>{const o=n.getSelectedElement();if(t&&o&&r.isImage(o)){const t=this.editor.model.createPositionAfter(o);this._uploadImage(e,i,t)}else this._uploadImage(e,i)}))}_uploadImage(e,t,n){const r=this.editor,i=r.plugins.get(fg).createLoader(e),o=r.plugins.get("ImageUtils");var s,a;i&&o.insertImage((s=((e,t)=>{for(var n in t||(t={}))Ny.call(t,n)&&Dy(e,n,t[n]);if(My)for(var n of My(t))Ey.call(t,n)&&Dy(e,n,t[n]);return e})({},t),a={uploadId:i.id},Ay(s,Sy(a))),n)}}class Oy extends qi{constructor(e){super(e),e.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}static get requires(){return[fg,Yp,bf,Ob]}static get pluginName(){return"ImageUploadEditing"}init(){const e=this.editor,t=e.model.document,n=e.conversion,r=e.plugins.get(fg),i=e.plugins.get("ImageUtils"),o=e.plugins.get("ClipboardPipeline"),s=hy(e.config.get("image.upload.types")),a=new Ty(e);e.commands.add("uploadImage",a),e.commands.add("imageUpload",a),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(e.editing.view.document,"clipboardInput",((t,n)=>{if(r=n.dataTransfer,Array.from(r.types).includes("text/html")&&""!==r.getData("text/html"))return;var r;const i=Array.from(n.dataTransfer.files).filter((e=>!!e&&s.test(e.type)));i.length&&(t.stop(),e.model.change((t=>{n.targetRanges&&t.setSelection(n.targetRanges.map((t=>e.editing.mapper.toModelRange(t)))),e.model.enqueueChange((()=>{e.execute("uploadImage",{file:i})}))})))})),this.listenTo(o,"inputTransformation",((t,n)=>{const o=Array.from(e.editing.view.createRangeIn(n.content)).map((e=>e.item)).filter((e=>function(e,t){return!(!e.isInlineImageView(t)||!t.getAttribute("src")||!t.getAttribute("src").match(/^data:image\/\w+;base64,/g)&&!t.getAttribute("src").match(/^blob:/g))}(i,e)&&!e.getAttribute("uploadProcessed"))).map((e=>({promise:py(e),imageElement:e})));if(!o.length)return;const s=new Kd(e.editing.view.document);for(const e of o){s.setAttribute("uploadProcessed",!0,e.imageElement);const t=r.createLoader(e.promise);t&&(s.setAttribute("src","",e.imageElement),s.setAttribute("uploadId",t.id,e.imageElement))}})),e.editing.view.document.on("dragover",((e,t)=>{t.preventDefault()})),t.on("change",(()=>{const n=t.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),i=new Set;for(const t of n)if("insert"==t.type&&"$text"!=t.name){const n=t.position.nodeAfter,o="$graveyard"==t.position.root.rootName;for(const t of Ly(e,n)){const e=t.getAttribute("uploadId");if(!e)continue;const n=r.loaders.get(e);n&&(o?i.has(e)||n.abort():(i.add(e),this._uploadImageElements.set(e,t),"idle"==n.status&&this._readAndUpload(n)))}}})),this.on("uploadComplete",((e,{imageElement:t,data:n})=>{const r=n.urls?n.urls:n;this.editor.model.change((e=>{e.setAttribute("src",r.default,t),this._parseAndSetSrcsetAttributeOnImage(r,t,e)}))}),{priority:"low"})}afterInit(){const e=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&e.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(e){const t=this.editor,n=t.model,r=t.locale.t,i=t.plugins.get(fg),o=t.plugins.get(Yp),s=t.plugins.get("ImageUtils"),a=this._uploadImageElements;return n.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","reading",a.get(e.id))})),e.read().then((()=>{const r=e.upload(),i=a.get(e.id);if(u.isSafari){const e=t.editing.mapper.toViewElement(i),n=s.findViewImgElement(e);t.editing.view.once("render",(()=>{if(!n.parent)return;const e=t.editing.view.domConverter.mapViewToDom(n.parent);if(!e)return;const r=e.style.display;e.style.display="none",e._ckHack=e.offsetHeight,e.style.display=r}))}return n.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","uploading",i)})),r})).then((t=>{n.enqueueChange({isUndoable:!1},(n=>{const r=a.get(e.id);n.setAttribute("uploadStatus","complete",r),this.fire("uploadComplete",{data:t,imageElement:r})})),l()})).catch((t=>{if("error"!==e.status&&"aborted"!==e.status)throw t;"error"==e.status&&t&&o.showWarning(t,{title:r("Upload failed"),namespace:"upload"}),n.enqueueChange({isUndoable:!1},(t=>{t.remove(a.get(e.id))})),l()}));function l(){n.enqueueChange({isUndoable:!1},(t=>{const n=a.get(e.id);t.removeAttribute("uploadId",n),t.removeAttribute("uploadStatus",n),a.delete(e.id)})),i.destroyLoader(e)}}_parseAndSetSrcsetAttributeOnImage(e,t,n){let r=0;const i=Object.keys(e).filter((e=>{const t=parseInt(e,10);if(!isNaN(t))return r=Math.max(r,t),!0})).map((t=>`${e[t]} ${t}w`)).join(", ");""!=i&&n.setAttribute("srcset",{data:i,width:r},t)}}function Ly(e,t){const n=e.plugins.get("ImageUtils");return Array.from(e.model.createRangeOn(t)).filter((e=>n.isImage(e.item))).map((e=>e.item))}var Py=o(1568);Kr()(Py.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Py.Z.locals;var Iy=o(3535);Kr()(Iy.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Iy.Z.locals;var zy=o(6270);Kr()(zy.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),zy.Z.locals;class Ry extends Gi{constructor(e,t){super(e),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(t.map((e=>{if(e.isDefault)for(const t of e.modelElements)this._defaultStyles[t]=e.name;return[e.name,e]})))}refresh(){const e=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!e,this.isEnabled?e.hasAttribute("imageStyle")?this.value=e.getAttribute("imageStyle"):this.value=this._defaultStyles[e.name]:this.value=!1}execute(e={}){const t=this.editor,n=t.model,r=t.plugins.get("ImageUtils");n.change((t=>{const i=e.value;let o=r.getClosestSelectedImageElement(n.document.selection);i&&this.shouldConvertImageType(i,o)&&(this.editor.execute(r.isBlockImage(o)?"imageTypeInline":"imageTypeBlock"),o=r.getClosestSelectedImageElement(n.document.selection)),!i||this._styles.get(i).isDefault?t.removeAttribute("imageStyle",o):t.setAttribute("imageStyle",i,o)}))}shouldConvertImageType(e,t){return!this._styles.get(e).modelElements.includes(t.name)}}var By=Object.defineProperty,Fy=Object.getOwnPropertySymbols,Yy=Object.prototype.hasOwnProperty,Hy=Object.prototype.propertyIsEnumerable,$y=(e,t,n)=>t in e?By(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uy=(e,t)=>{for(var n in t||(t={}))Yy.call(t,n)&&$y(e,n,t[n]);if(Fy)for(var n of Fy(t))Hy.call(t,n)&&$y(e,n,t[n]);return e};const{objectFullWidth:Wy,objectInline:Vy,objectLeft:qy,objectRight:Zy,objectCenter:Gy,objectBlockLeft:Ky,objectBlockRight:Qy}=nh,Jy={get inline(){return{name:"inline",title:"In line",icon:Vy,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:qy,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:Ky,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:Gy,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:Zy,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:Qy,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:Gy,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:Zy,modelElements:["imageBlock"],className:"image-style-side"}}},Xy={full:Wy,left:Ky,right:Qy,center:Gy,inlineLeft:qy,inlineRight:Zy,inline:Vy},ev=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function tv(e){x("image-style-configuration-definition-invalid",e)}const nv={normalizeStyles:function(e){return(e.configuredStyles.options||[]).map((e=>function(e){return e="string"==typeof e?Jy[e]?Uy({},Jy[e]):{name:e}:function(e,t){const n=Uy({},t);for(const r in e)Object.prototype.hasOwnProperty.call(t,r)||(n[r]=e[r]);return n}(Jy[e.name],e),"string"==typeof e.icon&&(e.icon=Xy[e.icon]||e.icon),e}(e))).filter((t=>function(e,{isBlockPluginLoaded:t,isInlinePluginLoaded:n}){const{modelElements:r,name:i}=e;if(!(r&&r.length&&i))return tv({style:e}),!1;{const i=[t?"imageBlock":null,n?"imageInline":null];if(!r.some((e=>i.includes(e))))return x("image-style-missing-dependency",{style:e,missingPlugins:r.map((e=>"imageBlock"===e?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(t,e)))},getDefaultStylesConfiguration:function(e,t){return e&&t?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:e?{options:["block","side"]}:t?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(e){return e.has("ImageBlockEditing")&&e.has("ImageInlineEditing")?[...ev]:[]},warnInvalidStyle:tv,DEFAULT_OPTIONS:Jy,DEFAULT_ICONS:Xy,DEFAULT_DROPDOWN_DEFINITIONS:ev};function rv(e,t){for(const n of t)if(n.name===e)return n}class iv extends qi{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[Ob]}init(){const{normalizeStyles:e,getDefaultStylesConfiguration:t}=nv,n=this.editor,r=n.plugins.has("ImageBlockEditing"),i=n.plugins.has("ImageInlineEditing");n.config.define("image.styles",t(r,i)),this.normalizedStyles=e({configuredStyles:n.config.get("image.styles"),isBlockPluginLoaded:r,isInlinePluginLoaded:i}),this._setupConversion(r,i),this._setupPostFixer(),n.commands.add("imageStyle",new Ry(n,this.normalizedStyles))}_setupConversion(e,t){const n=this.editor,r=n.model.schema,i=(o=this.normalizedStyles,(e,t,n)=>{if(!n.consumable.consume(t.item,e.name))return;const r=rv(t.attributeNewValue,o),i=rv(t.attributeOldValue,o),s=n.mapper.toViewElement(t.item),a=n.writer;i&&a.removeClass(i.className,s),r&&a.addClass(r.className,s)});var o;const s=function(e){const t={imageInline:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageInline"))),imageBlock:e.filter((e=>!e.isDefault&&e.modelElements.includes("imageBlock")))};return(e,n,r)=>{if(!n.modelRange)return;const i=n.viewItem,o=Br(n.modelRange.getItems());if(o&&r.schema.checkAttribute(o,"imageStyle"))for(const e of t[o.name])r.consumable.consume(i,{classes:e.className})&&r.writer.setAttribute("imageStyle",e.name,o)}}(this.normalizedStyles);n.editing.downcastDispatcher.on("attribute:imageStyle",i),n.data.downcastDispatcher.on("attribute:imageStyle",i),e&&(r.extend("imageBlock",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:figure",s,{priority:"low"})),t&&(r.extend("imageInline",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:img",s,{priority:"low"}))}_setupPostFixer(){const e=this.editor,t=e.model.document,n=e.plugins.get(Ob),r=new Map(this.normalizedStyles.map((e=>[e.name,e])));t.registerPostFixer((e=>{let i=!1;for(const o of t.differ.getChanges())if("insert"==o.type||"attribute"==o.type&&"imageStyle"==o.attributeKey){let t="insert"==o.type?o.position.nodeAfter:o.range.start.nodeAfter;if(t&&t.is("element","paragraph")&&t.childCount>0&&(t=t.getChild(0)),!n.isImage(t))continue;const s=t.getAttribute("imageStyle");if(!s)continue;const a=r.get(s);a&&a.modelElements.includes(t.name)||(e.removeAttribute("imageStyle",t),i=!0)}return i}))}}var ov=o(5083);Kr()(ov.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),ov.Z.locals;class sv extends qi{static get requires(){return[iv]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const e=this.editor.t;return{"Wrap text":e("Wrap text"),"Break text":e("Break text"),"In line":e("In line"),"Full size image":e("Full size image"),"Side image":e("Side image"),"Left aligned image":e("Left aligned image"),"Centered image":e("Centered image"),"Right aligned image":e("Right aligned image")}}init(){const e=this.editor.plugins,t=this.editor.config.get("image.toolbar")||[],n=av(e.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const e of n)this._createButton(e);const r=av([...t.filter(Y),...nv.getDefaultDropdownDefinitions(e)],this.localizedDefaultStylesTitles);for(const e of r)this._createDropdown(e,n)}_createDropdown(e,t){const n=this.editor.ui.componentFactory;n.add(e.name,(r=>{let i;const{defaultItem:o,items:s,title:a}=e,l=s.filter((e=>t.find((({name:t})=>lv(t)===e)))).map((e=>{const t=n.create(e);return e===o&&(i=t),t}));s.length!==l.length&&nv.warnInvalidStyle({dropdown:e});const c=yh(r,mh),u=c.buttonView,d=u.arrowView;return vh(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),u.set({label:cv(a,i.label),class:null,tooltip:!0}),d.unbind("label"),d.set({label:a}),u.bind("icon").toMany(l,"isOn",((...e)=>{const t=e.findIndex(Yo);return t<0?i.icon:l[t].icon})),u.bind("label").toMany(l,"isOn",((...e)=>{const t=e.findIndex(Yo);return cv(a,t<0?i.label:l[t].label)})),u.bind("isOn").toMany(l,"isOn",((...e)=>e.some(Yo))),u.bind("class").toMany(l,"isOn",((...e)=>e.some(Yo)?"ck-splitbutton_flatten":void 0)),u.on("execute",(()=>{l.some((({isOn:e})=>e))?c.isOpen=!c.isOpen:i.fire("execute")})),c.bind("isEnabled").toMany(l,"isEnabled",((...e)=>e.some(Yo))),this.listenTo(c,"execute",(()=>{this.editor.editing.view.focus()})),c}))}_createButton(e){const t=e.name;this.editor.ui.componentFactory.add(lv(t),(n=>{const r=this.editor.commands.get("imageStyle"),i=new ji(n);return i.set({label:e.title,icon:e.icon,tooltip:!0,isToggleable:!0}),i.bind("isEnabled").to(r,"isEnabled"),i.bind("isOn").to(r,"value",(e=>e===t)),i.on("execute",this._executeCommand.bind(this,t)),i}))}_executeCommand(e){this.editor.execute("imageStyle",{value:e}),this.editor.editing.view.focus()}}function av(e,t){for(const n of e)t[n.title]&&(n.title=t[n.title]);return e}function lv(e){return`imageStyle:${e}`}function cv(e,t){return(e?e+": ":"")+t}class uv extends qi{static get pluginName(){return"IndentEditing"}init(){const e=this.editor;e.commands.add("indent",new Qi(e)),e.commands.add("outdent",new Qi(e))}}const dv='',hv='';class pv extends qi{static get pluginName(){return"IndentUI"}init(){const e=this.editor,t=e.locale,n=e.t,r="ltr"==t.uiLanguageDirection?dv:hv,i="ltr"==t.uiLanguageDirection?hv:dv;this._defineButton("indent",n("Increase indent"),r),this._defineButton("outdent",n("Decrease indent"),i)}_defineButton(e,t,n){const r=this.editor;r.ui.componentFactory.add(e,(i=>{const o=r.commands.get(e),s=new ji(i);return s.set({label:t,icon:n,tooltip:!0}),s.bind("isEnabled").to(o,"isEnabled"),this.listenTo(s,"execute",(()=>{r.execute(e),r.editing.view.focus()})),s}))}}class fv{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(e){Array.isArray(e)?e.forEach((e=>this._definitions.add(e))):this._definitions.add(e)}getDispatcher(){return e=>{e.on("attribute:linkHref",((e,t,n)=>{if(!n.consumable.test(t.item,"attribute:linkHref"))return;if(!t.item.is("selection")&&!n.schema.isInline(t.item))return;const r=n.writer,i=r.document.selection;for(const e of this._definitions){const o=r.createAttributeElement("a",e.attributes,{priority:5});e.classes&&r.addClass(e.classes,o);for(const t in e.styles)r.setStyle(t,e.styles[t],o);r.setCustomProperty("link",!0,o),e.callback(t.attributeNewValue)?t.item.is("selection")?r.wrap(i.getFirstRange(),o):r.wrap(n.mapper.toViewRange(t.range),o):r.unwrap(n.mapper.toViewRange(t.range),o)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return e=>{e.on("attribute:linkHref:imageBlock",((e,t,{writer:n,mapper:r})=>{const i=r.toViewElement(t.item),o=Array.from(i.getChildren()).find((e=>e.is("element","a")));for(const e of this._definitions){const r=Hr(e.attributes);if(e.callback(t.attributeNewValue)){for(const[e,t]of r)"class"===e?n.addClass(t,o):n.setAttribute(e,t,o);e.classes&&n.addClass(e.classes,o);for(const t in e.styles)n.setStyle(t,e.styles[t],o)}else{for(const[e,t]of r)"class"===e?n.removeClass(t,o):n.removeAttribute(e,o);e.classes&&n.removeClass(e.classes,o);for(const t in e.styles)n.removeStyle(t,o)}}}))}}}var mv=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const gv=function(e){return mv.test(e)};var bv="\\ud800-\\udfff",yv="["+bv+"]",vv="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",_v="\\ud83c[\\udffb-\\udfff]",wv="[^"+bv+"]",kv="(?:\\ud83c[\\udde6-\\uddff]){2}",xv="[\\ud800-\\udbff][\\udc00-\\udfff]",Cv="(?:"+vv+"|"+_v+")?",jv="[\\ufe0e\\ufe0f]?",Av=jv+Cv+"(?:\\u200d(?:"+[wv,kv,xv].join("|")+")"+jv+Cv+")*",Sv="(?:"+[wv+vv+"?",vv,kv,xv,yv].join("|")+")",Mv=RegExp(_v+"(?="+_v+")|"+Sv+Av,"g");const Nv=function(e){return gv(e)?function(e){return e.match(Mv)||[]}(e):function(e){return e.split("")}(e)},Ev=function(e){e=No(e);var t=gv(e)?Nv(e):void 0,n=t?t[0]:e.charAt(0),r=t?function(e,t,n){var r=e.length;return n=void 0===n?r:n,!t&&n>=r?e:Oo(e,t,n)}(t,1).join(""):e.slice(1);return n.toUpperCase()+r},Dv=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,Tv=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,Ov=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,Lv=/^((\w+:(\/{2,})?)|(\W))/i,Pv="Ctrl+K";function Iv(e,{writer:t}){const n=t.createAttributeElement("a",{href:e},{priority:5});return t.setCustomProperty("link",!0,n),n}function zv(e){const t=String(e);return function(e){return!!e.replace(Dv,"").match(Tv)}(t)?t:"#"}function Rv(e,t){return!!e&&t.checkAttribute(e.name,"linkHref")}function Bv(e,t){const n=(r=e,Ov.test(r)?"mailto:":t);var r;const i=!!n&&!Fv(e);return e&&i?n+e:e}function Fv(e){return Lv.test(e)}function Yv(e){window.open(e,"_blank","noopener")}class Hv extends Gi{constructor(){super(...arguments),this.manualDecorators=new Rr,this.automaticDecorators=new fv}restoreManualDecoratorStates(){for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}refresh(){const e=this.editor.model,t=e.document.selection,n=t.getSelectedElement()||Br(t.getSelectedBlocks());Rv(n,e.schema)?(this.value=n.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttribute(n,"linkHref")):(this.value=t.getAttribute("linkHref"),this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref"));for(const e of this.manualDecorators)e.value=this._getDecoratorStateFromModel(e.id)}execute(e,t={}){const n=this.editor.model,r=n.document.selection,i=[],o=[];for(const e in t)t[e]?i.push(e):o.push(e);n.change((t=>{if(r.isCollapsed){const s=r.getFirstPosition();if(r.hasAttribute("linkHref")){const a=$v(r);let l=Gf(s,"linkHref",r.getAttribute("linkHref"),n);r.getAttribute("linkHref")===a&&(l=this._updateLinkContent(n,t,l,e)),t.setAttribute("linkHref",e,l),i.forEach((e=>{t.setAttribute(e,!0,l)})),o.forEach((e=>{t.removeAttribute(e,l)})),t.setSelection(t.createPositionAfter(l.end.nodeBefore))}else if(""!==e){const o=Hr(r.getAttributes());o.set("linkHref",e),i.forEach((e=>{o.set(e,!0)}));const{end:a}=n.insertContent(t.createText(e,o),s);t.setSelection(a)}["linkHref",...i,...o].forEach((e=>{t.removeSelectionAttribute(e)}))}else{const s=n.schema.getValidRanges(r.getRanges(),"linkHref"),a=[];for(const e of r.getSelectedBlocks())n.schema.checkAttribute(e,"linkHref")&&a.push(t.createRangeOn(e));const l=a.slice();for(const e of s)this._isRangeToUpdate(e,a)&&l.push(e);for(const s of l){let a=s;if(1===l.length){const i=$v(r);r.getAttribute("linkHref")===i&&(a=this._updateLinkContent(n,t,s,e),t.setSelection(t.createSelection(a)))}t.setAttribute("linkHref",e,a),i.forEach((e=>{t.setAttribute(e,!0,a)})),o.forEach((e=>{t.removeAttribute(e,a)}))}}}))}_getDecoratorStateFromModel(e){const t=this.editor.model,n=t.document.selection,r=n.getSelectedElement();return Rv(r,t.schema)?r.getAttribute(e):n.getAttribute(e)}_isRangeToUpdate(e,t){for(const n of t)if(n.containsRange(e))return!1;return!0}_updateLinkContent(e,t,n,r){const i=t.createText(r,{linkHref:r});return e.insertContent(i,n)}}function $v(e){if(e.isCollapsed){const t=e.getFirstPosition();return t.textNode&&t.textNode.data}{const t=Array.from(e.getFirstRange().getItems());if(t.length>1)return null;const n=t[0];return n.is("$text")||n.is("$textProxy")?n.data:null}}class Uv extends Gi{refresh(){const e=this.editor.model,t=e.document.selection,n=t.getSelectedElement();Rv(n,e.schema)?this.isEnabled=e.schema.checkAttribute(n,"linkHref"):this.isEnabled=e.schema.checkAttributeInSelection(t,"linkHref")}execute(){const e=this.editor,t=this.editor.model,n=t.document.selection,r=e.commands.get("link");t.change((e=>{const i=n.isCollapsed?[Gf(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),t)]:t.schema.getValidRanges(n.getRanges(),"linkHref");for(const t of i)if(e.removeAttribute("linkHref",t),r)for(const n of r.manualDecorators)e.removeAttribute(n.id,t)}))}}class Wv extends(Z()){constructor({id:e,label:t,attributes:n,classes:r,styles:i,defaultValue:o}){super(),this.id=e,this.set("value",void 0),this.defaultValue=o,this.label=t,this.attributes=n,this.classes=r,this.styles=i}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}var Vv=o(9773);Kr()(Vv.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Vv.Z.locals;var qv=Object.defineProperty,Zv=Object.getOwnPropertySymbols,Gv=Object.prototype.hasOwnProperty,Kv=Object.prototype.propertyIsEnumerable,Qv=(e,t,n)=>t in e?qv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jv=(e,t)=>{for(var n in t||(t={}))Gv.call(t,n)&&Qv(e,n,t[n]);if(Zv)for(var n of Zv(t))Kv.call(t,n)&&Qv(e,n,t[n]);return e};const Xv="automatic",e_=/^(https?:)?\/\//;class t_ extends qi{static get pluginName(){return"LinkEditing"}static get requires(){return[Pf,kf,bf]}constructor(e){super(e),e.config.define("link",{addTargetToExternalLinks:!1})}init(){const e=this.editor;e.model.schema.extend("$text",{allowAttributes:"linkHref"}),e.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:Iv}),e.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(e,t)=>Iv(zv(e),t)}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:e=>e.getAttribute("href")}}),e.commands.add("link",new Hv(e)),e.commands.add("unlink",new Uv(e));const t=function(e,t){const n={"Open in a new tab":e("Open in a new tab"),Downloadable:e("Downloadable")};return t.forEach((e=>("label"in e&&n[e.label]&&(e.label=n[e.label]),e))),t}(e.t,function(e){const t=[];if(e)for(const[n,r]of Object.entries(e)){const e=Object.assign({},r,{id:`link${Ev(n)}`});t.push(e)}return t}(e.config.get("link.decorators")));this._enableAutomaticDecorators(t.filter((e=>e.mode===Xv))),this._enableManualDecorators(t.filter((e=>"manual"===e.mode))),e.plugins.get(Pf).registerAttribute("linkHref"),function(e,t,n,r){const i=e.editing.view,o=new Set;i.document.registerPostFixer((n=>{const i=e.model.document.selection;let s=!1;if(i.hasAttribute(t)){const a=Gf(i.getFirstPosition(),t,i.getAttribute(t),e.model),l=e.editing.mapper.toViewRange(a);for(const e of l.getItems())e.is("element","a")&&!e.hasClass(r)&&(n.addClass(r,e),o.add(e),s=!0)}return s})),e.conversion.for("editingDowncast").add((e=>{function t(){i.change((e=>{for(const t of o.values())e.removeClass(r,t),o.delete(t)}))}e.on("insert",t,{priority:"highest"}),e.on("remove",t,{priority:"highest"}),e.on("attribute",t,{priority:"highest"}),e.on("selection",t,{priority:"highest"})}))}(e,"linkHref",0,"ck-link_selected"),this._enableLinkOpen(),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink(),this._enableClipboardIntegration()}_enableAutomaticDecorators(e){const t=this.editor,n=t.commands.get("link").automaticDecorators;t.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:Xv,callback:e=>!!e&&e_.test(e),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(e),n.length&&t.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(e){if(!e.length)return;const t=this.editor,n=t.commands.get("link").manualDecorators;e.forEach((e=>{t.model.schema.extend("$text",{allowAttributes:e.id});const r=new Wv(e);n.add(r),t.conversion.for("downcast").attributeToElement({model:r.id,view:(e,{writer:t,schema:n},{item:i})=>{if((i.is("selection")||n.isInline(i))&&e){const e=t.createAttributeElement("a",r.attributes,{priority:5});r.classes&&t.addClass(r.classes,e);for(const n in r.styles)t.setStyle(n,r.styles[n],e);return t.setCustomProperty("link",!0,e),e}}}),t.conversion.for("upcast").elementToAttribute({view:Jv({name:"a"},r._createPattern()),model:{key:r.id}})}))}_enableLinkOpen(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",((e,t)=>{if(!(u.isMac?t.domEvent.metaKey:t.domEvent.ctrlKey))return;let n=t.domTarget;if("a"!=n.tagName.toLowerCase()&&(n=n.closest("a")),!n)return;const r=n.getAttribute("href");r&&(e.stop(),t.preventDefault(),Yv(r))}),{context:"$capture"}),this.listenTo(t,"keydown",((t,n)=>{const r=e.commands.get("link").value;r&&n.keyCode===Mr.enter&&n.altKey&&(t.stop(),Yv(r))}))}_enableInsertContentSelectionAttributesFixer(){const e=this.editor.model,t=e.document.selection;this.listenTo(e,"insertContent",(()=>{const n=t.anchor.nodeBefore,r=t.anchor.nodeAfter;t.hasAttribute("linkHref")&&n&&n.hasAttribute("linkHref")&&(r&&r.hasAttribute("linkHref")||e.change((t=>{n_(t,i_(e.schema))})))}),{priority:"low"})}_enableClickingAfterLink(){const e=this.editor,t=e.model;e.editing.view.addObserver(Gd);let n=!1;this.listenTo(e.editing.view.document,"mousedown",(()=>{n=!0})),this.listenTo(e.editing.view.document,"selectionChange",(()=>{if(!n)return;n=!1;const e=t.document.selection;if(!e.isCollapsed)return;if(!e.hasAttribute("linkHref"))return;const r=e.getFirstPosition(),i=Gf(r,"linkHref",e.getAttribute("linkHref"),t);(r.isTouching(i.start)||r.isTouching(i.end))&&t.change((e=>{n_(e,i_(t.schema))}))}))}_enableTypingOverLink(){const e=this.editor,t=e.editing.view;let n=null,r=!1;this.listenTo(t.document,"delete",(()=>{r=!0}),{priority:"high"}),this.listenTo(e.model,"deleteContent",(()=>{const t=e.model.document.selection;t.isCollapsed||(r?r=!1:r_(e)&&function(e){const t=e.document.selection,n=t.getFirstPosition(),r=t.getLastPosition(),i=n.nodeAfter;return!!i&&(!!i.is("$text")&&(!!i.hasAttribute("linkHref")&&(i===(r.textNode||r.nodeBefore)||Gf(n,"linkHref",i.getAttribute("linkHref"),e).containsRange(e.createRange(n,r),!0))))}(e.model)&&(n=t.getAttributes()))}),{priority:"high"}),this.listenTo(e.model,"insertContent",((t,[i])=>{r=!1,r_(e)&&n&&(e.model.change((e=>{for(const[t,r]of n)e.setAttribute(t,r,i)})),n=null)}),{priority:"high"})}_handleDeleteContentAfterLink(){const e=this.editor,t=e.model,n=t.document.selection,r=e.editing.view;let i=!1,o=!1;this.listenTo(r.document,"delete",((e,t)=>{o="backward"===t.direction}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{i=!1;const e=n.getFirstPosition(),r=n.getAttribute("linkHref");if(!r)return;const o=Gf(e,"linkHref",r,t);i=o.containsPosition(e)||o.end.isEqual(e)}),{priority:"high"}),this.listenTo(t,"deleteContent",(()=>{o&&(o=!1,i||e.model.enqueueChange((e=>{n_(e,i_(t.schema))})))}),{priority:"low"})}_enableClipboardIntegration(){const e=this.editor,t=e.model,n=this.editor.config.get("link.defaultProtocol");n&&this.listenTo(e.plugins.get("ClipboardPipeline"),"contentInsertion",((e,r)=>{t.change((e=>{const t=e.createRangeIn(r.content);for(const r of t.getItems())if(r.hasAttribute("linkHref")){const t=Bv(r.getAttribute("linkHref"),n);e.setAttribute("linkHref",t,r)}}))}))}}function n_(e,t){e.removeSelectionAttribute("linkHref");for(const n of t)e.removeSelectionAttribute(n)}function r_(e){return e.model.change((e=>e.batch)).isTyping}function i_(e){return e.getDefinition("$text").allowAttributes.filter((e=>e.startsWith("link")))}var o_=o(7754);Kr()(o_.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),o_.Z.locals;class s_ extends Jr{constructor(e,t){super(e),this.focusTracker=new Fr,this.keystrokes=new Yr,this._focusables=new Zr;const n=e.t;this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),nh.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),nh.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(t),this.children=this._createFormChildren(t.manualDecorators),this._focusCycler=new Hi({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const r=["ck","ck-link-form","ck-responsive-form"];t.manualDecorators.length&&r.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:r,tabindex:"-1"},children:this.children})}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((e,t)=>(e[t.name]=t.isOn,e)),{})}render(){super.render(),a({view:this}),[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const e=this.locale.t,t=new Ti(this.locale,Ch);return t.label=e("Link URL"),t}_createButton(e,t,n,r){const i=new ji(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),r&&i.delegate("execute").to(this,r),i}_createManualDecoratorSwitches(e){const t=this.createCollection();for(const n of e.manualDecorators){const r=new Si(this.locale);r.set({name:n.id,label:n.label,withText:!0}),r.bind("isOn").toMany([n,e],"value",((e,t)=>void 0===t&&void 0===e?!!n.defaultValue:!!e)),r.on("execute",(()=>{n.set("value",!r.isOn)})),t.add(r)}return t}_createFormChildren(e){const t=this.createCollection();if(t.add(this.urlInputView),e.length){const e=new Jr;e.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((e=>({tag:"li",children:[e],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),t.add(e)}return t.add(this.saveButtonView),t.add(this.cancelButtonView),t}}var a_=o(2347);Kr()(a_.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),a_.Z.locals;class l_ extends Jr{constructor(e){super(e),this.focusTracker=new Fr,this.keystrokes=new Yr,this._focusables=new Zr;const t=e.t;this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(t("Unlink"),'',"unlink"),this.editButtonView=this._createButton(t("Edit link"),nh.pencil,"edit"),this.set("href",void 0),this._focusCycler=new Hi({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","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render(),[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(e,t,n){const r=new ji(this.locale);return r.set({label:e,icon:t,tooltip:!0}),r.delegate("execute").to(this,n),r}_createPreviewButton(){const e=new ji(this.locale),t=this.bindTemplate,n=this.t;return e.set({withText:!0,tooltip:n("Open link in new tab")}),e.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:t.to("href",(e=>e&&zv(e))),target:"_blank",rel:"noopener noreferrer"}}),e.bind("label").to(this,"href",(e=>e||n("This link has no URL"))),e.bind("isEnabled").to(this,"href",(e=>!!e)),e.template.tag="a",e.template.eventListeners={},e}}const c_="link-ui";class u_ extends qi{constructor(){super(...arguments),this.actionsView=null,this.formView=null}static get requires(){return[Vp]}static get pluginName(){return"LinkUI"}init(){const e=this.editor;e.editing.view.addObserver(Zd),this._balloon=e.plugins.get(Vp),this._createToolbarLinkButton(),this._enableBalloonActivators(),e.conversion.for("editingDowncast").markerToHighlight({model:c_,view:{classes:["ck-fake-link-selection"]}}),e.conversion.for("editingDowncast").markerToElement({model:c_,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView&&this.formView.destroy(),this.actionsView&&this.actionsView.destroy()}_createViews(){this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._enableUserBalloonInteractions()}_createActionsView(){const e=this.editor,t=new l_(e.locale),n=e.commands.get("link"),r=e.commands.get("unlink");return t.bind("href").to(n,"value"),t.editButtonView.bind("isEnabled").to(n),t.unlinkButtonView.bind("isEnabled").to(r),this.listenTo(t,"edit",(()=>{this._addFormView()})),this.listenTo(t,"unlink",(()=>{e.execute("unlink"),this._hideUI()})),t.keystrokes.set("Esc",((e,t)=>{this._hideUI(),t()})),t.keystrokes.set(Pv,((e,t)=>{this._addFormView(),t()})),t}_createFormView(){const e=this.editor,t=e.commands.get("link"),n=e.config.get("link.defaultProtocol"),r=new(i(s_))(e.locale,t);return r.urlInputView.fieldView.bind("value").to(t,"value"),r.urlInputView.bind("isEnabled").to(t,"isEnabled"),r.saveButtonView.bind("isEnabled").to(t),this.listenTo(r,"submit",(()=>{const{value:t}=r.urlInputView.fieldView.element,i=Bv(t,n);e.execute("link",i,r.getDecoratorSwitchesState()),this._closeFormView()})),this.listenTo(r,"cancel",(()=>{this._closeFormView()})),r.keystrokes.set("Esc",((e,t)=>{this._closeFormView(),t()})),r}_createToolbarLinkButton(){const e=this.editor,t=e.commands.get("link"),n=e.t;e.ui.componentFactory.add("link",(e=>{const r=new ji(e);return r.isEnabled=!0,r.label=n("Link"),r.icon='',r.keystroke=Pv,r.tooltip=!0,r.isToggleable=!0,r.bind("isEnabled").to(t,"isEnabled"),r.bind("isOn").to(t,"value",(e=>!!e)),this.listenTo(r,"execute",(()=>this._showUI(!0))),r}))}_enableBalloonActivators(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),e.keystrokes.set(Pv,((t,n)=>{n(),e.commands.get("link").isEnabled&&this._showUI(!0)}))}_enableUserBalloonInteractions(){this.editor.keystrokes.set("Tab",((e,t)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),t())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((e,t)=>{this._isUIVisible&&(this._hideUI(),t())})),r({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:()=>[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this.actionsView||this._createViews(),this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this.formView||this._createViews(),this._isFormInPanel)return;const e=this.editor.commands.get("link");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=e.value||""}_closeFormView(){const e=this.editor.commands.get("link");e.restoreManualDecoratorStates(),void 0!==e.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(e=!1){this.formView||this._createViews(),this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),e&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),e&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const e=this.editor;this.stopListening(e.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),e.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const e=this.editor,t=e.editing.view.document;let n=this._getSelectedLinkElement(),r=o();const i=()=>{const e=this._getSelectedLinkElement(),t=o();n&&!e||!n&&t!==r?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=e,r=t};function o(){return t.selection.focus.getAncestors().reverse().find((e=>e.is("element")))}this.listenTo(e.ui,"update",i),this.listenTo(this._balloon,"change:visibleView",i)}get _isFormInPanel(){return!!this.formView&&this._balloon.hasView(this.formView)}get _areActionsInPanel(){return!!this.actionsView&&this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return!!this.actionsView&&this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){const e=this._balloon.visibleView;return!!this.formView&&e==this.formView||this._areActionsVisible}_getBalloonPositionData(){const e=this.editor.editing.view,t=this.editor.model,n=e.document;let r;if(t.markers.has(c_)){const t=Array.from(this.editor.editing.mapper.markerNameToElements(c_)),n=e.createRange(e.createPositionBefore(t[0]),e.createPositionAfter(t[t.length-1]));r=e.domConverter.viewRangeToDom(n)}else r=()=>{const t=this._getSelectedLinkElement();return t?e.domConverter.mapViewToDom(t):e.domConverter.viewRangeToDom(n.selection.getFirstRange())};return{target:r}}_getSelectedLinkElement(){const e=this.editor.editing.view,t=e.document.selection,n=t.getSelectedElement();if(t.isCollapsed||n&&fm(n))return d_(t.getFirstPosition());{const n=t.getFirstRange().getTrimmed(),r=d_(n.start),i=d_(n.end);return r&&r==i&&e.createRangeIn(r).getTrimmed().isEqual(n)?r:null}}_showFakeVisualSelection(){const e=this.editor.model;e.change((t=>{const n=e.document.selection.getFirstRange();if(e.markers.has(c_))t.updateMarker(c_,{range:n});else if(n.start.isAtEnd){const r=n.start.getLastMatchingPosition((({item:t})=>!e.schema.isContent(t)),{boundaries:n});t.addMarker(c_,{usingOperation:!1,affectsData:!1,range:t.createRange(r,n.end)})}else t.addMarker(c_,{usingOperation:!1,affectsData:!1,range:n})}))}_hideFakeVisualSelection(){const e=this.editor.model;e.markers.has(c_)&&e.change((e=>{e.removeMarker(c_)}))}}function d_(e){return e.getAncestors().find((e=>{return(t=e).is("attributeElement")&&!!t.getCustomProperty("link");var t}))||null}const h_=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63})))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i");class p_ extends qi{static get requires(){return[Df]}static get pluginName(){return"AutoLink"}init(){const e=this.editor.model.document.selection;e.on("change:range",(()=>{this.isEnabled=!e.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const e=this.editor,t=new Lf(e.model,(e=>{if(!function(e){return e.length>4&&" "===e[e.length-1]&&" "!==e[e.length-2]}(e))return;const t=f_(e.substr(0,e.length-1));return t?{url:t}:void 0}));t.on("matched:data",((t,n)=>{const{batch:r,range:i,url:o}=n;if(!r.isTyping)return;const s=i.end.getShiftedBy(-1),a=s.getShiftedBy(-o.length),l=e.model.createRange(a,s);this._applyAutoLink(o,l)})),t.bind("isEnabled").to(this)}_enableEnterHandling(){const e=this.editor,t=e.model,n=e.commands.get("enter");n&&n.on("execute",(()=>{const e=t.document.selection.getFirstPosition();if(!e.parent.previousSibling)return;const n=t.createRangeIn(e.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(n)}))}_enableShiftEnterHandling(){const e=this.editor,t=e.model,n=e.commands.get("shiftEnter");n&&n.on("execute",(()=>{const e=t.document.selection.getFirstPosition(),n=t.createRange(t.createPositionAt(e.parent,0),e.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(n)}))}_checkAndApplyAutoLinkOnRange(e){const t=this.editor.model,{text:n,range:r}=Of(e,t),i=f_(n);if(i){const e=t.createRange(r.end.getShiftedBy(-i.length),r.end);this._applyAutoLink(i,e)}}_applyAutoLink(e,t){const n=this.editor.model,r=Bv(e,this.editor.config.get("link.defaultProtocol"));this.isEnabled&&function(e,t){return t.schema.checkAttributeInSelection(t.createSelection(e),"linkHref")}(t,n)&&Fv(r)&&!function(e){const t=e.start.nodeAfter;return!!t&&t.hasAttribute("linkHref")}(t)&&this._persistAutoLink(r,t)}_persistAutoLink(e,t){const n=this.editor.model,r=this.editor.plugins.get("Delete");n.enqueueChange((i=>{i.setAttribute("linkHref",e,t),n.enqueueChange((()=>{r.requestUndoOnBackspace()}))}))}}function f_(e){const t=h_.exec(e);return t?t[2]:null}var m_=o(111);Kr()(m_.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),m_.Z.locals,Symbol.iterator,Symbol.iterator,Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;var g_=o(5730);Kr()(g_.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),g_.Z.locals;var b_=o(4564);function y_(e,t,n,r){const i=t.parent,o=n.mapper,s=n.writer;let a=o.toViewPosition(r.createPositionBefore(e));const l=w_(e.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:e.getAttribute("listIndent")}),c=e.previousSibling;if(l&&l.getAttribute("listIndent")==e.getAttribute("listIndent")){const e=o.toViewElement(l);a=s.breakContainer(s.createPositionAfter(e))}else if(c&&"listItem"==c.name){a=o.toViewPosition(r.createPositionAt(c,"end"));const e=o.findMappedViewAncestor(a),t=function(e){for(const t of e.getChildren())if("ul"==t.name||"ol"==t.name)return t;return null}(e);a=t?s.createPositionBefore(t):s.createPositionAt(e,"end")}else a=o.toViewPosition(r.createPositionBefore(e));if(a=__(a),s.insert(a,i),c&&"listItem"==c.name){const e=o.toViewElement(c),n=s.createRange(s.createPositionAt(e,0),a).getWalker({ignoreElementEnd:!0});for(const e of n)if(e.item.is("element","li")){const r=s.breakContainer(s.createPositionBefore(e.item)),i=e.item.parent,o=s.createPositionAt(t,"end");v_(s,o.nodeBefore,o.nodeAfter),s.move(s.createRangeOn(i),o),n._position=r}}else{const n=i.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let r=null;for(const t of n.getChildren()){const n=o.toModelElement(t);if(!(n&&n.getAttribute("listIndent")>e.getAttribute("listIndent")))break;r=t}r&&(s.breakContainer(s.createPositionAfter(r)),s.move(s.createRangeOn(r.parent),s.createPositionAt(t,"end")))}}v_(s,i,i.nextSibling),v_(s,i.previousSibling,i)}function v_(e,t,n){return!t||!n||"ul"!=t.name&&"ol"!=t.name||t.name!=n.name||t.getAttribute("class")!==n.getAttribute("class")?null:e.mergeContainers(e.createPositionAfter(t))}function __(e){return e.getLastMatchingPosition((e=>e.item.is("uiElement")))}function w_(e,t){const n=!!t.sameIndent,r=!!t.smallerIndent,i=t.listIndent;let o=e;for(;o&&"listItem"==o.name;){const e=o.getAttribute("listIndent");if(n&&i==e||r&&i>e)return o;o="forward"===t.direction?o.nextSibling:o.previousSibling}return null}function k_(e,t,n,r){e.ui.componentFactory.add(t,(i=>{const o=e.commands.get(t),s=new ji(i);return s.set({label:n,icon:r,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(o,"value","isEnabled"),s.on("execute",(()=>{e.execute(t),e.editing.view.focus()})),s}))}function x_(e,t){const n=[],r=e.parent,i={ignoreElementEnd:!1,startPosition:e,shallow:!0,direction:t},o=r.getAttribute("listIndent"),s=[...new pl(i)].filter((e=>e.item.is("element"))).map((e=>e.item));for(const e of s){if(!e.is("element","listItem"))break;if(e.getAttribute("listIndent")o)){if(e.getAttribute("listType")!==r.getAttribute("listType"))break;if(e.getAttribute("listStyle")!==r.getAttribute("listStyle"))break;if(e.getAttribute("listReversed")!==r.getAttribute("listReversed"))break;if(e.getAttribute("listStart")!==r.getAttribute("listStart"))break;"backward"===t?n.unshift(e):n.push(e)}}return n}Kr()(b_.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),b_.Z.locals;const C_=["disc","circle","square"],j_=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function A_(){const e=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||e?0:is.call(this)}class S_ extends qi{static get pluginName(){return"ListUI"}init(){const e=this.editor.t;k_(this.editor,"numberedList",e("Numbered List"),''),k_(this.editor,"bulletedList",e("Bulleted List"),'')}}const M_={},N_={},E_={},D_=[{listStyle:"disc",typeAttribute:"disc",listType:"bulleted"},{listStyle:"circle",typeAttribute:"circle",listType:"bulleted"},{listStyle:"square",typeAttribute:"square",listType:"bulleted"},{listStyle:"decimal",typeAttribute:"1",listType:"numbered"},{listStyle:"decimal-leading-zero",typeAttribute:null,listType:"numbered"},{listStyle:"lower-roman",typeAttribute:"i",listType:"numbered"},{listStyle:"upper-roman",typeAttribute:"I",listType:"numbered"},{listStyle:"lower-alpha",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-alpha",typeAttribute:"A",listType:"numbered"},{listStyle:"lower-latin",typeAttribute:"a",listType:"numbered"},{listStyle:"upper-latin",typeAttribute:"A",listType:"numbered"}];for(const{listStyle:e,typeAttribute:t,listType:n}of D_)M_[e]=n,N_[e]=t,t&&(E_[t]=e);var T_=o(4721);Kr()(T_.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),T_.Z.locals;var O_=o(6082);Kr()(O_.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),O_.Z.locals;var L_=o(2417);Kr()(L_.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),L_.Z.locals;class P_ extends Gi{constructor(e,t){super(e),this._indentBy="forward"==t?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const e=this.editor.model,t=e.document;let n=Array.from(t.selection.getSelectedBlocks());e.change((e=>{const t=n[n.length-1];let r=t.nextSibling;for(;r&&"listItem"==r.name&&r.getAttribute("listIndent")>t.getAttribute("listIndent");)n.push(r),r=r.nextSibling;this._indentBy<0&&(n=n.reverse());for(const t of n){const n=t.getAttribute("listIndent")+this._indentBy;n<0?e.rename(t,"paragraph"):e.setAttribute("listIndent",n,t)}this.fire("_executeCleanup",n)}))}_checkEnabled(){const e=Br(this.editor.model.document.selection.getSelectedBlocks());if(!e||!e.is("element","listItem"))return!1;if(this._indentBy>0){const t=e.getAttribute("listIndent"),n=e.getAttribute("listType");let r=e.previousSibling;for(;r&&r.is("element","listItem")&&r.getAttribute("listIndent")>=t;){if(r.getAttribute("listIndent")==t)return r.getAttribute("listType")==n;r=r.previousSibling}return!1}return!0}}class I_ extends Gi{constructor(e,t){super(e),this.type=t}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(e={}){const t=this.editor.model,n=t.document,r=Array.from(n.selection.getSelectedBlocks()).filter((e=>R_(e,t.schema))),i=void 0!==e.forceValue?!e.forceValue:this.value;t.change((e=>{if(i){let t=r[r.length-1].nextSibling,n=Number.POSITIVE_INFINITY,i=[];for(;t&&"listItem"==t.name&&0!==t.getAttribute("listIndent");){const e=t.getAttribute("listIndent");e=n;)o>i.getAttribute("listIndent")&&(o=i.getAttribute("listIndent")),i.getAttribute("listIndent")==o&&e[t?"unshift":"push"](i),i=i[t?"previousSibling":"nextSibling"]}}function R_(e,t){return t.checkChild(e.parent,"listItem")&&!t.isObject(e)}class B_ extends qi{static get pluginName(){return"ListUtils"}getListTypeFromListStyleType(e){return function(e){return C_.includes(e)?"bulleted":j_.includes(e)?"numbered":null}(e)}getSelectedListItems(e){return function(e){let t=[...e.document.selection.getSelectedBlocks()].filter((e=>e.is("element","listItem"))).map((t=>{const n=e.change((e=>e.createPositionAt(t,0)));return[...x_(n,"backward"),...x_(n,"forward")]})).flat();return t=[...new Set(t)],t}(e)}getSiblingNodes(e,t){return x_(e,t)}}function F_(e){return(t,n,r)=>{const i=r.consumable;if(!i.test(n.item,"insert")||!i.test(n.item,"attribute:listType")||!i.test(n.item,"attribute:listIndent"))return;i.consume(n.item,"insert"),i.consume(n.item,"attribute:listType"),i.consume(n.item,"attribute:listIndent");const o=n.item;y_(o,function(e,t){const n=t.mapper,r=t.writer,i="numbered"==e.getAttribute("listType")?"ol":"ul",o=function(e){const t=e.createContainerElement("li");return t.getFillerOffset=A_,t}(r),s=r.createContainerElement(i,null);return r.insert(r.createPositionAt(s,0),o),n.bindElements(e,o),o}(o,r),r,e)}}const Y_=(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const r=n.mapper.toViewElement(t.item),i=n.writer;i.breakContainer(i.createPositionBefore(r)),i.breakContainer(i.createPositionAfter(r));const o=r.parent,s="numbered"==t.attributeNewValue?"ol":"ul";i.rename(s,o)},H_=(e,t,n)=>{n.consumable.consume(t.item,e.name);const r=n.mapper.toViewElement(t.item).parent,i=n.writer;v_(i,r,r.nextSibling),v_(i,r.previousSibling,r)},$_=(e,t,n)=>{if(n.consumable.test(t.item,e.name)&&"listItem"!=t.item.name){let e=n.mapper.toViewPosition(t.range.start);const r=n.writer,i=[];for(;("ul"==e.parent.name||"ol"==e.parent.name)&&(e=r.breakContainer(e),"li"==e.parent.name);){const t=e,n=r.createPositionAt(e.parent,"end");if(!t.isEqual(n)){const e=r.remove(r.createRange(t,n));i.push(e)}e=r.createPositionAfter(e.parent)}if(i.length>0){for(let t=0;t0){const t=v_(r,n,n.nextSibling);t&&t.parent==n&&e.offset--}}v_(r,e.nodeBefore,e.nodeAfter)}}},U_=(e,t,n)=>{const r=n.mapper.toViewPosition(t.position),i=r.nodeBefore,o=r.nodeAfter;v_(n.writer,i,o)},W_=(e,t,n)=>{if(n.consumable.consume(t.viewItem,{name:!0})){const e=n.writer,r=e.createElement("listItem"),i=function(e){let t=0,n=e.parent;for(;n;){if(n.is("element","li"))t++;else{const e=n.previousSibling;e&&e.is("element","li")&&t++}n=n.parent}return t}(t.viewItem);e.setAttribute("listIndent",i,r);const o=t.viewItem.parent&&"ol"==t.viewItem.parent.name?"numbered":"bulleted";if(e.setAttribute("listType",o,r),!n.safeInsert(r,t.modelCursor))return;const s=function(e,t,n){const{writer:r,schema:i}=n;let o=r.createPositionAfter(e);for(const s of t)if("ul"==s.name||"ol"==s.name)o=n.convertItem(s,o).modelCursor;else{const t=n.convertItem(s,r.createPositionAt(e,"end")),a=t.modelRange.start.nodeAfter;a&&a.is("element")&&!i.checkChild(e,a.name)&&(e=t.modelCursor.parent.is("element","listItem")?t.modelCursor.parent:K_(t.modelCursor),o=r.createPositionAfter(e))}return o}(r,t.viewItem.getChildren(),n);t.modelRange=e.createRange(t.modelCursor,s),n.updateConversionResult(r,t)}},V_=(e,t,n)=>{if(n.consumable.test(t.viewItem,{name:!0})){const e=Array.from(t.viewItem.getChildren());for(const t of e)!t.is("element","li")&&!J_(t)&&t._remove()}},q_=(e,t,n)=>{if(n.consumable.test(t.viewItem,{name:!0})){if(0===t.viewItem.childCount)return;const e=[...t.viewItem.getChildren()];let n=!1;for(const t of e)n&&!J_(t)&&t._remove(),J_(t)&&(n=!0)}};function Z_(e){return(t,n)=>{if(n.isPhantom)return;const r=n.modelPosition.nodeBefore;if(r&&r.is("element","listItem")){const t=n.mapper.toViewElement(r),i=t.getAncestors().find(J_),o=e.createPositionAt(t,0).getWalker();for(const e of o){if("elementStart"==e.type&&e.item.is("element","li")){n.viewPosition=e.previousPosition;break}if("elementEnd"==e.type&&e.item==i){n.viewPosition=e.nextPosition;break}}}}}const G_=function(e,[t,n]){let r,i=t.is("documentFragment")?t.getChild(0):t;if(r=n?this.createSelection(n):this.document.selection,i&&i.is("element","listItem")){const e=r.getFirstPosition();let t=null;if(e.parent.is("element","listItem")?t=e.parent:e.nodeBefore&&e.nodeBefore.is("element","listItem")&&(t=e.nodeBefore),t){const e=t.getAttribute("listIndent");if(e>0)for(;i&&i.is("element","listItem");)i._setAttribute("listIndent",i.getAttribute("listIndent")+e),i=i.nextSibling}}};function K_(e){const t=new pl({startPosition:e});let n;do{n=t.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function Q_(e,t,n,r,i,o){const s=w_(t.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:e}),a=i.mapper,l=i.writer,c=s?s.getAttribute("listIndent"):null;let u;if(s)if(c==e){const e=a.toViewElement(s).parent;u=l.createPositionAfter(e)}else{const e=o.createPositionAt(s,"end");u=a.toViewPosition(e)}else u=n;u=__(u);for(const e of[...r.getChildren()])J_(e)&&(u=l.move(l.createRangeOn(e),u).end,v_(l,e,e.nextSibling),v_(l,e.previousSibling,e))}function J_(e){return e.is("element","ol")||e.is("element","ul")}class X_ extends qi{static get pluginName(){return"ListEditing"}static get requires(){return[nm,Df,B_]}init(){const e=this.editor;e.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const t=e.data,n=e.editing;var r;e.model.document.registerPostFixer((t=>function(e,t){const n=e.document.differ.getChanges(),r=new Map;let i=!1;for(const r of n)if("insert"==r.type&&"listItem"==r.name)o(r.position);else if("insert"==r.type&&"listItem"!=r.name){if("$text"!=r.name){const n=r.position.nodeAfter;n.hasAttribute("listIndent")&&(t.removeAttribute("listIndent",n),i=!0),n.hasAttribute("listType")&&(t.removeAttribute("listType",n),i=!0),n.hasAttribute("listStyle")&&(t.removeAttribute("listStyle",n),i=!0),n.hasAttribute("listReversed")&&(t.removeAttribute("listReversed",n),i=!0),n.hasAttribute("listStart")&&(t.removeAttribute("listStart",n),i=!0);for(const t of Array.from(e.createRangeIn(n)).filter((e=>e.item.is("element","listItem"))))o(t.previousPosition)}o(r.position.getShiftedBy(r.length))}else"remove"==r.type&&"listItem"==r.name?o(r.position):("attribute"==r.type&&"listIndent"==r.attributeKey||"attribute"==r.type&&"listType"==r.attributeKey)&&o(r.range.start);for(const e of r.values())s(e),a(e);return i;function o(e){const t=e.nodeBefore;if(t&&t.is("element","listItem")){let e=t;if(r.has(e))return;for(let t=e.previousSibling;t&&t.is("element","listItem");t=e.previousSibling)if(e=t,r.has(e))return;r.set(t,e)}else{const t=e.nodeAfter;t&&t.is("element","listItem")&&r.set(t,t)}}function s(e){let n=0,r=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(o>n){let s;null===r?(r=o-n,s=n):(r>o&&(r=o),s=o-r),t.setAttribute("listIndent",s,e),i=!0}else r=null,n=e.getAttribute("listIndent")+1;e=e.nextSibling}}function a(e){let n=[],r=null;for(;e&&e.is("element","listItem");){const o=e.getAttribute("listIndent");if(r&&r.getAttribute("listIndent")>o&&(n=n.slice(0,o+1)),0!=o)if(n[o]){const r=n[o];e.getAttribute("listType")!=r&&(t.setAttribute("listType",r,e),i=!0)}else n[o]=e.getAttribute("listType");r=e,e=e.nextSibling}}}(e.model,t))),n.mapper.registerViewToModelLength("li",ew),t.mapper.registerViewToModelLength("li",ew),n.mapper.on("modelToViewPosition",Z_(n.view)),n.mapper.on("viewToModelPosition",(r=e.model,(e,t)=>{const n=t.viewPosition,i=n.parent,o=t.mapper;if("ul"==i.name||"ol"==i.name){if(n.isAtEnd){const e=o.toModelElement(n.nodeBefore),i=o.getModelLength(n.nodeBefore);t.modelPosition=r.createPositionBefore(e).getShiftedBy(i)}else{const e=o.toModelElement(n.nodeAfter);t.modelPosition=r.createPositionBefore(e)}e.stop()}else if("li"==i.name&&n.nodeBefore&&("ul"==n.nodeBefore.name||"ol"==n.nodeBefore.name)){const s=o.toModelElement(i);let a=1,l=n.nodeBefore;for(;l&&J_(l);)a+=o.getModelLength(l),l=l.previousSibling;t.modelPosition=r.createPositionBefore(s).getShiftedBy(a),e.stop()}})),t.mapper.on("modelToViewPosition",Z_(n.view)),e.conversion.for("editingDowncast").add((t=>{t.on("insert",$_,{priority:"high"}),t.on("insert:listItem",F_(e.model)),t.on("attribute:listType:listItem",Y_,{priority:"high"}),t.on("attribute:listType:listItem",H_,{priority:"low"}),t.on("attribute:listIndent:listItem",function(e){return(t,n,r)=>{if(!r.consumable.consume(n.item,"attribute:listIndent"))return;const i=r.mapper.toViewElement(n.item),o=r.writer;o.breakContainer(o.createPositionBefore(i)),o.breakContainer(o.createPositionAfter(i));const s=i.parent,a=s.previousSibling,l=o.createRangeOn(s);o.remove(l),a&&a.nextSibling&&v_(o,a,a.nextSibling),Q_(n.attributeOldValue+1,n.range.start,l.start,i,r,e),y_(n.item,i,r,e);for(const e of n.item.getChildren())r.consumable.consume(e,"insert")}}(e.model)),t.on("remove:listItem",function(e){return(t,n,r)=>{const i=r.mapper.toViewPosition(n.position).getLastMatchingPosition((e=>!e.item.is("element","li"))).nodeAfter,o=r.writer;o.breakContainer(o.createPositionBefore(i)),o.breakContainer(o.createPositionAfter(i));const s=i.parent,a=s.previousSibling,l=o.createRangeOn(s),c=o.remove(l);a&&a.nextSibling&&v_(o,a,a.nextSibling),Q_(r.mapper.toModelElement(i).getAttribute("listIndent")+1,n.position,l.start,i,r,e);for(const e of o.createRangeIn(c).getItems())r.mapper.unbindViewElement(e);t.stop()}}(e.model)),t.on("remove",U_,{priority:"low"})})),e.conversion.for("dataDowncast").add((t=>{t.on("insert",$_,{priority:"high"}),t.on("insert:listItem",F_(e.model))})),e.conversion.for("upcast").add((e=>{e.on("element:ul",V_,{priority:"high"}),e.on("element:ol",V_,{priority:"high"}),e.on("element:li",q_,{priority:"high"}),e.on("element:li",W_)})),e.model.on("insertContent",G_,{priority:"high"}),e.commands.add("numberedList",new I_(e,"numbered")),e.commands.add("bulletedList",new I_(e,"bulleted")),e.commands.add("indentList",new P_(e,"forward")),e.commands.add("outdentList",new P_(e,"backward"));const i=n.view.document;this.listenTo(i,"enter",((e,t)=>{const n=this.editor.model.document,r=n.selection.getLastPosition().parent;n.selection.isCollapsed&&"listItem"==r.name&&r.isEmpty&&(this.editor.execute("outdentList"),t.preventDefault(),e.stop())}),{context:"li"}),this.listenTo(i,"delete",((e,t)=>{if("backward"!==t.direction)return;const n=this.editor.model.document.selection;if(!n.isCollapsed)return;const r=n.getFirstPosition();if(!r.isAtStart)return;const i=r.parent;"listItem"===i.name&&(i.previousSibling&&"listItem"===i.previousSibling.name||(this.editor.execute("outdentList"),t.preventDefault(),e.stop()))}),{context:"li"}),this.listenTo(e.editing.view.document,"tab",((t,n)=>{const r=n.shiftKey?"outdentList":"indentList";this.editor.commands.get(r).isEnabled&&(e.execute(r),n.stopPropagation(),n.preventDefault(),t.stop())}),{context:"li"})}afterInit(){const e=this.editor.commands,t=e.get("indent"),n=e.get("outdent");t&&t.registerChildCommand(e.get("indentList")),n&&n.registerChildCommand(e.get("outdentList"))}}function ew(e){let t=1;for(const n of e.getChildren())if("ul"==n.name||"ol"==n.name)for(const e of n.getChildren())t+=ew(e);return t}Dr("Ctrl+Enter");var tw=o(1199);function nw(e,t){const n=(n,r,i)=>{if(!i.consumable.consume(r.item,n.name))return;const o=r.attributeNewValue,s=i.writer,a=i.mapper.toViewElement(r.item),l=[...a.getChildren()].find((e=>e.getCustomProperty("media-content")));s.remove(l);const c=e.getMediaViewElement(s,o,t);s.insert(s.createPositionAt(a,0),c)};return e=>{e.on("attribute:url:media",n)}}function rw(e,t,n,r){return e.createContainerElement("figure",{class:"media"},[t.getMediaViewElement(e,n,r),e.createSlot()])}function iw(e){const t=e.getSelectedElement();return t&&t.is("element","media")?t:null}function ow(e,t,n,r){e.change((i=>{const o=i.createElement("media",{url:t});e.insertObject(o,n,null,{setSelection:"on",findOptimalPosition:r?"auto":void 0})}))}Kr()(tw.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),tw.Z.locals;class sw extends Gi{refresh(){const e=this.editor.model,t=e.document.selection,n=iw(t);this.value=n?n.getAttribute("url"):void 0,this.isEnabled=function(e){const t=e.getSelectedElement();return!!t&&"media"===t.name}(t)||function(e,t){let n=_m(e,t).start.parent;return n.isEmpty&&!t.schema.isLimit(n)&&(n=n.parent),t.schema.checkChild(n,"media")}(t,e)}execute(e){const t=this.editor.model,n=t.document.selection,r=iw(n);r?t.change((t=>{t.setAttribute("url",e,r)})):ow(t,e,n,!0)}}class aw{constructor(e,t){const n=t.providers,r=t.extraProviders||[],i=new Set(t.removeProviders),o=n.concat(r).filter((e=>{const t=e.name;return t?!i.has(t):(x("media-embed-no-provider-name",{provider:e}),!1)}));this.locale=e,this.providerDefinitions=o}hasMedia(e){return!!this._getMedia(e)}getMediaViewElement(e,t,n){return this._getMedia(t).getViewElement(e,n)}_getMedia(e){if(!e)return new lw(this.locale);e=e.trim();for(const t of this.providerDefinitions){const n=t.html,r=Lr(t.url);for(const t of r){const r=this._getUrlMatches(e,t);if(r)return new lw(this.locale,e,r,n)}}return null}_getUrlMatches(e,t){let n=e.match(t);if(n)return n;let r=e.replace(/^https?:\/\//,"");return n=r.match(t),n||(r=r.replace(/^www\./,""),n=r.match(t),n||null)}}class lw{constructor(e,t,n,r){this.url=this._getValidUrl(t),this._locale=e,this._match=n,this._previewRenderer=r}getViewElement(e,t){const n={};let r;if(t.renderForEditingView||t.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(n["data-oembed-url"]=this.url),t.renderForEditingView&&(n.class="ck-media__wrapper");const i=this._getPreviewHtml(t);r=e.createRawElement("div",n,((e,t)=>{t.setContentOf(e,i)}))}else this.url&&(n.url=this.url),r=e.createEmptyElement(t.elementName,n);return e.setCustomProperty("media-content",!0,r),r}_getPreviewHtml(e){return this._previewRenderer?this._previewRenderer(this._match):this.url&&e.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const e=new xi,t=this._locale.t;return e.content='',e.viewBox="0 0 64 42",new Xr({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,"data-cke-tooltip-text":t("Open media in new tab")},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]}]}]}).render().outerHTML}_getValidUrl(e){return e?e.match(/^https?/)?e:"https://"+e:null}}var cw=o(7442);Kr()(cw.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),cw.Z.locals;class uw extends qi{constructor(e){super(e),e.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:/^dailymotion\.com\/video\/(\w+)/,html:e=>``},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:e=>``},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)(?:&t=(\d+))?/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/,/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/,/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/],html:e=>{const t=e[1],n=e[2];return``}},{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:e=>``},{name:"instagram",url:/^instagram\.com\/p\/(\w+)/},{name:"twitter",url:/^twitter\.com/},{name:"googleMaps",url:[/^google\.com\/maps/,/^goo\.gl\/maps/,/^maps\.google\.com/,/^maps\.app\.goo\.gl/]},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new aw(e.locale,e.config.get("mediaEmbed"))}static get pluginName(){return"MediaEmbedEditing"}init(){const e=this.editor,t=e.model.schema,n=e.t,r=e.conversion,i=e.config.get("mediaEmbed.previewsInData"),o=e.config.get("mediaEmbed.elementName"),s=this.registry;e.commands.add("mediaEmbed",new sw(e)),t.register("media",{inheritAllFrom:"$blockObject",allowAttributes:["url"]}),r.for("dataDowncast").elementToStructure({model:"media",view:(e,{writer:t})=>{const n=e.getAttribute("url");return rw(t,s,n,{elementName:o,renderMediaPreview:!!n&&i})}}),r.for("dataDowncast").add(nw(s,{elementName:o,renderMediaPreview:i})),r.for("editingDowncast").elementToStructure({model:"media",view:(e,{writer:t})=>{const r=e.getAttribute("url");return function(e,t,n){return t.setCustomProperty("media",!0,e),mm(e,t,{label:n})}(rw(t,s,r,{elementName:o,renderForEditingView:!0}),t,n("media widget"))}}),r.for("editingDowncast").add(nw(s,{elementName:o,renderForEditingView:!0})),r.for("upcast").elementToElement({view:e=>["oembed",o].includes(e.name)&&e.getAttribute("url")?{name:!0}:null,model:(e,{writer:t})=>{const n=e.getAttribute("url");return s.hasMedia(n)?t.createElement("media",{url:n}):null}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(e,{writer:t})=>{const n=e.getAttribute("data-oembed-url");return s.hasMedia(n)?t.createElement("media",{url:n}):null}}).add((e=>{e.on("element:figure",((e,t,n)=>{if(!n.consumable.consume(t.viewItem,{name:!0,classes:"media"}))return;const{modelRange:r,modelCursor:i}=n.convertChildren(t.viewItem,t.modelCursor);t.modelRange=r,t.modelCursor=i,Br(r.getItems())||n.consumable.revert(t.viewItem,{name:!0,classes:"media"})}))}))}}const dw=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class hw extends qi{constructor(e){super(e),this._timeoutId=null,this._positionToInsert=null}static get requires(){return[Wm,Df,hg]}static get pluginName(){return"AutoMediaEmbed"}init(){const e=this.editor,t=e.model.document,n=e.plugins.get("ClipboardPipeline");this.listenTo(n,"inputTransformation",(()=>{const e=t.selection.getFirstRange(),n=Hu.fromPosition(e.start);n.stickiness="toPrevious";const r=Hu.fromPosition(e.end);r.stickiness="toNext",t.once("change:data",(()=>{this._embedMediaBetweenPositions(n,r),n.detach(),r.detach()}),{priority:"high"})})),e.commands.get("undo").on("execute",(()=>{this._timeoutId&&(Zn.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)}),{priority:"high"})}_embedMediaBetweenPositions(e,t){const n=this.editor,r=n.plugins.get(uw).registry,i=new Ul(e,t),o=i.getWalker({ignoreElementEnd:!0});let s="";for(const e of o)e.item.is("$textProxy")&&(s+=e.item.data);s=s.trim(),s.match(dw)&&r.hasMedia(s)&&n.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=Hu.fromPosition(e),this._timeoutId=Zn.window.setTimeout((()=>{n.model.change((e=>{this._timeoutId=null,e.remove(i),i.detach();let t=null;"$graveyard"!==this._positionToInsert.root.rootName&&(t=this._positionToInsert),ow(n.model,s,t,!1),this._positionToInsert.detach(),this._positionToInsert=null})),n.plugins.get(Df).requestUndoOnBackspace()}),100)):i.detach()}}var pw=o(9292);Kr()(pw.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),pw.Z.locals;class fw extends Jr{constructor(e,t){super(t);const n=t.t;this.focusTracker=new Fr,this.keystrokes=new Yr,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),nh.check,"ck-button-save"),this.saveButtonView.type="submit",this.saveButtonView.bind("isEnabled").to(this,"mediaURLInputValue",(e=>!!e)),this.cancelButtonView=this._createButton(n("Cancel"),nh.cancel,"ck-button-cancel","cancel"),this._focusables=new Zr,this._focusCycler=new Hi({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._validators=e,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView,this.saveButtonView,this.cancelButtonView]})}render(){super.render(),a({view:this}),[this.urlInputView,this.saveButtonView,this.cancelButtonView].forEach((e=>{this._focusables.add(e),this.focusTracker.add(e.element)})),this.keystrokes.listenTo(this.element);const e=e=>e.stopPropagation();this.keystrokes.set("arrowright",e),this.keystrokes.set("arrowleft",e),this.keystrokes.set("arrowup",e),this.keystrokes.set("arrowdown",e)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(e){this.urlInputView.fieldView.element.value=e.trim()}isValid(){this.resetFormStatus();for(const e of this._validators){const t=e(this);if(t)return this.urlInputView.errorText=t,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const e=this.locale.t,t=new Ti(this.locale,Ch),n=t.fieldView;return this._urlInputViewInfoDefault=e("Paste the media URL in the input."),this._urlInputViewInfoTip=e("Tip: Paste the URL into the content to embed faster."),t.label=e("Media URL"),t.infoText=this._urlInputViewInfoDefault,n.on("input",(()=>{t.infoText=n.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=n.element.value.trim()})),t}_createButton(e,t,n,r){const i=new ji(this.locale);return i.set({label:e,icon:t,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),r&&i.delegate("execute").to(this,r),i}}class mw extends qi{static get requires(){return[uw]}static get pluginName(){return"MediaEmbedUI"}init(){const e=this.editor,t=e.commands.get("mediaEmbed");e.ui.componentFactory.add("mediaEmbed",(e=>{const n=yh(e);return this._setUpDropdown(n,t),n}))}_setUpDropdown(e,t){const n=this.editor,r=n.t,o=e.buttonView,s=n.plugins.get(uw).registry;e.once("change:isOpen",(()=>{const r=new(i(fw))(function(e,t){return[t=>{if(!t.url.length)return e("The URL must not be empty.")},n=>{if(!t.hasMedia(n.url))return e("This media URL is not supported.")}]}(n.t,s),n.locale);e.panelView.children.add(r),o.on("open",(()=>{r.disableCssTransitions(),r.url=t.value||"",r.urlInputView.fieldView.select(),r.enableCssTransitions()}),{priority:"low"}),e.on("submit",(()=>{r.isValid()&&(n.execute("mediaEmbed",r.url),n.editing.view.focus())})),e.on("change:isOpen",(()=>r.resetFormStatus())),e.on("cancel",(()=>{n.editing.view.focus()})),r.delegate("submit","cancel").to(e),r.urlInputView.fieldView.bind("value").to(t,"value"),r.urlInputView.bind("isEnabled").to(t,"isEnabled")})),e.bind("isEnabled").to(t),o.set({label:r("Insert media"),icon:'',tooltip:!0})}}var gw=o(4652);function bw(e){if(e.startsWith("arabic-leading-zero"))return"decimal-leading-zero";switch(e){case"alpha-upper":return"upper-alpha";case"alpha-lower":return"lower-alpha";case"roman-upper":return"upper-roman";case"roman-lower":return"lower-roman";case"circle":case"disc":case"square":return e;default:return null}}function yw(e,t,n){const r=t.parent,i=n.createElement(e.type),o=r.getChildIndex(t)+1;return n.insertChild(o,i,r),e.style&&n.setStyle("list-style-type",e.style,i),e.startIndex&&e.startIndex>1&&n.setAttribute("start",e.startIndex,i),i}function vw(e){const t={},n=e.getStyle("mso-list");if(n){const e=n.match(/(^|\s{1,100})l(\d+)/i),r=n.match(/\s{0,100}lfo(\d+)/i),i=n.match(/\s{0,100}level(\d+)/i);e&&r&&i&&(t.id=e[2],t.order=r[1],t.indent=parseInt(i[1]))}return t}function _w(e){return btoa(e.match(/\w{2}/g).map((e=>String.fromCharCode(parseInt(e,16)))).join(""))}Kr()(gw.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),gw.Z.locals;const ww=//i,kw=/xmlns:o="urn:schemas-microsoft-com/i;class xw{constructor(e){this.document=e}isActive(e){return ww.test(e)||kw.test(e)}execute(e){const{body:t,stylesString:n}=e._parsedData;(function(e,t){if(!e.childCount)return;const n=new Kd(e.document),r=function(e,t){const n=t.createRangeIn(e),r=new fo({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),i=[];for(const e of n)if("elementStart"===e.type&&r.match(e.item)){const t=vw(e.item);i.push({element:e.item,id:t.id,order:t.order,indent:t.indent})}return i}(e,n);if(!r.length)return;let i=null,o=1;r.forEach(((e,s)=>{const a=function(e,t){if(!e)return!0;if(e.id!==t.id)return t.indent-e.indent!=1;const n=t.element.previousSibling;return!n||!((r=n).is("element","ol")||r.is("element","ul"));var r}(r[s-1],e),l=(u=e,(c=a?null:r[s-1])?u.indent-c.indent:u.indent-1);var c,u;if(a&&(i=null,o=1),!i||0!==l){const r=function(e,t){const n=/mso-level-number-format:([^;]{0,100});/gi,r=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,i=new RegExp(`@list l${e.id}:level${e.indent}\\s*({[^}]*)`,"gi").exec(t);let o="decimal",s="ol",a=null;if(i&&i[1]){const t=n.exec(i[1]);if(t&&t[1]&&(o=t[1].trim(),s="bullet"!==o&&"image"!==o?"ol":"ul"),"bullet"===o){const t=function(e){const t=function(e){if(e.getChild(0).is("$text"))return null;for(const t of e.getChildren()){if(!t.is("element","span"))continue;const e=t.getChild(0);if(e)return e.is("$text")?e:e.getChild(0)}return null}(e);if(!t)return null;const n=t._data;return"o"===n?"circle":"·"===n?"disc":"§"===n?"square":null}(e.element);t&&(o=t)}else{const e=r.exec(i[1]);e&&e[1]&&(a=parseInt(e[1]))}}return{type:s,startIndex:a,style:bw(o)}}(e,t);if(i){if(e.indent>o){const e=i.getChild(i.childCount-1),t=e.getChild(e.childCount-1);i=yw(r,t,n),o+=1}else if(e.indente.indexOf(t)>-1))?o.push(n):n.getAttribute("src")||o.push(n)}for(const e of o)n.remove(e)}(r,e,n),function(e,t,n){const r=n.createRangeIn(t),i=[];for(const t of r)if("elementStart"==t.type&&t.item.is("element","v:shape")){const n=t.item.getAttribute("id");if(e.includes(n))continue;o(t.item.parent.getChildren(),n)||i.push(t.item)}for(const e of i){const t={src:s(e)};e.hasAttribute("alt")&&(t.alt=e.getAttribute("alt"));const r=n.createElement("img",t);n.insertChild(e.index+1,r,e.parent)}function o(e,t){for(const n of e)if(n.is("element")){if("img"==n.name&&n.getAttribute("v:shapes")==t)return!0;if(o(n.getChildren(),t))return!0}return!1}function s(e){for(const t of e.getChildren())if(t.is("element")&&t.getAttribute("src"))return t.getAttribute("src")}}(r,e,n),function(e,t){const n=t.createRangeIn(e),r=new fo({name:/v:(.+)/}),i=[];for(const e of n)"elementStart"==e.type&&r.match(e.item)&&i.push(e.item);for(const e of i)t.remove(e)}(e,n);const i=function(e,t){const n=t.createRangeIn(e),r=new fo({name:"img"}),i=[];for(const e of n)e.item.is("element")&&r.match(e.item)&&e.item.getAttribute("src").startsWith("file://")&&i.push(e.item);return i}(e,n);i.length&&function(e,t,n){if(e.length===t.length)for(let r=0;re.is("element")&&!r.includes(e.name)&&!i.includes(e.name)),{direction:t}),"forward"==t?o.nodeAfter:o.nodeBefore}function jw(e,t){return!!e&&e.is("element")&&t.includes(e.name)}const Aw=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class Sw{constructor(e){this.document=e}isActive(e){return Aw.test(e)}execute(e){const t=new Kd(this.document),{body:n}=e._parsedData;!function(e,t){for(const n of e.getChildren())if(n.is("element","b")&&"normal"===n.getStyle("font-weight")){const r=e.getChildIndex(n);t.remove(n),t.insertChild(r,n.getChildren(),e)}}(n,t),function(e,t){for(const n of t.createRangeIn(e)){const e=n.item;if(e.is("element","li")){const n=e.getChild(0);n&&n.is("element","p")&&t.unwrapElement(n)}}}(n,t),function(e,t){const n=new ws(t.document.stylesProcessor),r=new ua(n,{renderingMode:"data"}),i=r.blockElements,o=r.inlineObjectElements,s=[];for(const n of t.createRangeIn(e)){const e=n.item;if(e.is("element","br")){const n=Cw(e,"forward",t,{blockElements:i,inlineObjectElements:o}),r=Cw(e,"backward",t,{blockElements:i,inlineObjectElements:o}),a=jw(n,i);(jw(r,i)||a)&&s.push(e)}}for(const e of s)e.hasClass("Apple-interchange-newline")?t.remove(e):t.replace(e,t.createElement("p"))}(n,t),e.content=n}}const Mw=/(\s+)<\/span>/g,((e,t)=>1===t.length?" ":Array(t.length+1).join(" ").substr(0,t.length)))}function Dw(e,t,n,r,i=1){null!=t&&null!=i&&t>i?r.setAttribute(e,t,n):r.removeAttribute(e,n)}function Tw(e,t,n={}){const r=e.createElement("tableCell",n);return e.insertElement("paragraph",r),e.insert(r,t),r}function Ow(e,t){const n=t.parent.parent,r=parseInt(n.getAttribute("headingColumns")||"0"),{column:i}=e.getCellLocation(t);return!!r&&i{t.on(`element:${e}`,((e,t,{writer:n})=>{if(!t.modelRange)return;const r=t.modelRange.start.nodeAfter,i=n.createPositionAt(r,0);if(t.viewItem.isEmpty)return void n.insertElement("paragraph",i);const o=Array.from(r.getChildren());if(o.every((e=>e.is("element","$marker")))){const e=n.createElement("paragraph");n.insert(e,n.createPositionAt(r,0));for(const t of o)n.move(n.createRangeOn(t),n.createPositionAt(e,"end"))}}),{priority:"low"})}}function Pw(e){let t=0,n=0;const r=Array.from(e.getChildren()).filter((e=>"th"===e.name||"td"===e.name));for(;n1||i>1)&&this._recordSpans(n,i,r),this._shouldSkipSlot()||(t=this._formatOutValue(n)),this._nextCellAtColumn=this._column+r}return this._column++,this._column==this._nextCellAtColumn&&this._cellIndex++,t||this.next()}skipRow(e){this._skipRows.add(e)}_advanceToNextRow(){return this._row++,this._rowIndex++,this._column=0,this._cellIndex=0,this._nextCellAtColumn=-1,this.next()}_isOverEndRow(){return void 0!==this._endRow&&this._row>this._endRow}_isOverEndColumn(){return void 0!==this._endColumn&&this._column>this._endColumn}_formatOutValue(e,t=this._row,n=this._column){return{done:!1,value:new zw(this,e,t,n)}}_shouldSkipSlot(){const e=this._skipRows.has(this._row),t=this._rowthis._endColumn;return e||t||n||r}_getSpanned(){const e=this._spannedCells.get(this._row);return e&&e.get(this._column)||null}_recordSpans(e,t,n){const r={cell:e,row:this._row,column:this._column};for(let e=this._row;e{const i=n.getAttribute("headingRows")||0,o=r.createContainerElement("table",null,[]),s=r.createContainerElement("figure",{class:"table"},o);i>0&&r.insert(r.createPositionAt(o,"end"),r.createContainerElement("thead",null,r.createSlot((e=>e.is("element","tableRow")&&e.indexe.is("element","tableRow")&&e.index>=i))));for(const{positionOffset:e,filter:n}of t.additionalSlots)r.insert(r.createPositionAt(o,e),r.createSlot(n));return r.insert(r.createPositionAt(o,"after"),r.createSlot((e=>!e.is("element","tableRow")&&!t.additionalSlots.some((({filter:t})=>t(e)))))),t.asWidget?function(e,t){return t.setCustomProperty("table",!0,e),mm(e,t,{hasSelectionHandle:!0})}(s,r):s}}function Bw(e={}){return(t,{writer:n})=>{const r=t.parent,i=r.parent,o=i.getChildIndex(r),s=new Iw(i,{row:o}),a=i.getAttribute("headingRows")||0,l=i.getAttribute("headingColumns")||0;let c=null;for(const r of s)if(r.cell==t){const t=r.row{if(!t.parent.is("element","tableCell"))return null;if(!Yw(t))return null;if(e.asWidget)return n.createContainerElement("span",{class:"ck-table-bogus-paragraph"});{const e=n.createContainerElement("p");return n.setCustomProperty("dataPipeline:transparentRendering",!0,e),e}}}function Yw(e){return 1==e.parent.childCount&&!!e.getAttributeKeys().next().done}class Hw extends Gi{refresh(){const e=this.editor.model,t=e.document.selection,n=e.schema;this.isEnabled=function(e,t){const n=e.getFirstPosition().parent,r=n===n.root?n:n.parent;return t.checkChild(r,"table")}(t,n)}execute(e={}){const t=this.editor,n=t.model,r=t.plugins.get("TableUtils"),i=t.config.get("table.defaultHeadings.rows"),o=t.config.get("table.defaultHeadings.columns");void 0===e.headingRows&&i&&(e.headingRows=i),void 0===e.headingColumns&&o&&(e.headingColumns=o),n.change((t=>{const i=r.createTable(t,e);n.insertObject(i,null,null,{findOptimalPosition:"auto"}),t.setSelection(t.createPositionAt(i.getNodeByPath([0,0,0]),0))}))}}class $w extends Gi{constructor(e,t={}){super(e),this.order=t.order||"below"}refresh(){const e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){const e=this.editor,t=e.model.document.selection,n=e.plugins.get("TableUtils"),r="above"===this.order,i=n.getSelectionAffectedTableCells(t),o=n.getRowIndexes(i),s=r?o.first:o.last,a=i[0].findAncestor("table");n.insertRows(a,{at:r?s:s+1,copyStructureFromAbove:!r})}}class Uw extends Gi{constructor(e,t={}){super(e),this.order=t.order||"right"}refresh(){const e=this.editor.model.document.selection,t=!!this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(e).length;this.isEnabled=t}execute(){const e=this.editor,t=e.model.document.selection,n=e.plugins.get("TableUtils"),r="left"===this.order,i=n.getSelectionAffectedTableCells(t),o=n.getColumnIndexes(i),s=r?o.first:o.last,a=i[0].findAncestor("table");n.insertColumns(a,{columns:1,at:r?s:s+1})}}class Ww extends Gi{constructor(e,t={}){super(e),this.direction=t.direction||"horizontally"}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=1===e.length}execute(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection)[0];"horizontally"===this.direction?e.splitCellHorizontally(t,2):e.splitCellVertically(t,2)}}function Vw(e,t,n){const{startRow:r,startColumn:i,endRow:o,endColumn:s}=t,a=n.createElement("table"),l=o-r+1;for(let e=0;e0&&Dw("headingRows",o-n,e,i,0);const s=parseInt(t.getAttribute("headingColumns")||"0");s>0&&Dw("headingColumns",s-r,e,i,0)}(a,e,r,i,n),a}function qw(e,t,n=0){const r=[],i=new Iw(e,{startRow:n,endRow:t-1});for(const e of i){const{row:n,cellHeight:i}=e;n1&&(a.rowspan=l);const c=parseInt(e.getAttribute("colspan")||"1");c>1&&(a.colspan=c);const u=o+s,d=[...new Iw(i,{startRow:o,endRow:u,includeAllSlots:!0})];let h,p=null;for(const t of d){const{row:r,column:i,cell:o}=t;o===e&&void 0===h&&(h=i),void 0!==h&&h===i&&r===u&&(p=Tw(n,t.getPositionBefore(),a))}return Dw("rowspan",s,e,n),p}function Gw(e,t){const n=[],r=new Iw(e);for(const e of r){const{column:r,cellWidth:i}=e;r1&&(o.colspan=s);const a=parseInt(e.getAttribute("rowspan")||"1");a>1&&(o.rowspan=a);const l=Tw(r,r.createPositionAfter(e),o);return Dw("colspan",i,e,r),l}function Qw(e,t,n,r,i,o){const s=parseInt(e.getAttribute("colspan")||"1"),a=parseInt(e.getAttribute("rowspan")||"1");n+s-1>i&&Dw("colspan",i-n+1,e,o,1),t+a-1>r&&Dw("rowspan",r-t+1,e,o,1)}function Jw(e,t){const n=t.getColumns(e),r=new Array(n).fill(0);for(const{column:t}of new Iw(e))r[t]++;const i=r.reduce(((e,t,n)=>t?e:[...e,n]),[]);if(i.length>0){const n=i[i.length-1];return t.removeColumns(e,{at:n}),!0}return!1}function Xw(e,t){const n=[],r=t.getRows(e);for(let t=0;t0){const r=n[n.length-1];return t.removeRows(e,{at:r}),!0}return!1}function ek(e,t){Jw(e,t)||Xw(e,t)}function tk(e,t){const n=Array.from(new Iw(e,{startColumn:t.firstColumn,endColumn:t.lastColumn,row:t.lastRow}));if(n.every((({cellHeight:e})=>1===e)))return t.lastRow;const r=n[0].cellHeight-1;return t.lastRow+r}function nk(e,t){const n=Array.from(new Iw(e,{startRow:t.firstRow,endRow:t.lastRow,column:t.lastColumn}));if(n.every((({cellWidth:e})=>1===e)))return t.lastColumn;const r=n[0].cellWidth-1;return t.lastColumn+r}class rk extends Gi{constructor(e,t){super(e),this.direction=t.direction,this.isHorizontal="right"==this.direction||"left"==this.direction}refresh(){const e=this._getMergeableCell();this.value=e,this.isEnabled=!!e}execute(){const e=this.editor.model,t=e.document,n=this.editor.plugins.get("TableUtils").getTableCellsContainingSelection(t.selection)[0],r=this.value,i=this.direction;e.change((e=>{const t="right"==i||"down"==i,o=t?n:r,s=t?r:n,a=s.parent;!function(e,t,n){ik(e)||(ik(t)&&n.remove(n.createRangeIn(t)),n.move(n.createRangeIn(e),n.createPositionAt(t,"end"))),n.remove(e)}(s,o,e);const l=this.isHorizontal?"colspan":"rowspan",c=parseInt(n.getAttribute(l)||"1"),u=parseInt(r.getAttribute(l)||"1");e.setAttribute(l,c+u,o),e.setSelection(e.createRangeIn(o));const d=this.editor.plugins.get("TableUtils");ek(a.findAncestor("table"),d)}))}_getMergeableCell(){const e=this.editor.model.document,t=this.editor.plugins.get("TableUtils"),n=t.getTableCellsContainingSelection(e.selection)[0];if(!n)return;const r=this.isHorizontal?function(e,t,n){const r=e.parent.parent,i="right"==t?e.nextSibling:e.previousSibling,o=(r.getAttribute("headingColumns")||0)>0;if(!i)return;const s="right"==t?e:i,a="right"==t?i:e,{column:l}=n.getCellLocation(s),{column:c}=n.getCellLocation(a),u=parseInt(s.getAttribute("colspan")||"1"),d=Ow(n,s),h=Ow(n,a);return o&&d!=h?void 0:l+u===c?i:void 0}(n,this.direction,t):function(e,t,n){const r=e.parent,i=r.parent,o=i.getChildIndex(r);if("down"==t&&o===n.getRows(i)-1||"up"==t&&0===o)return null;const s=parseInt(e.getAttribute("rowspan")||"1"),a=i.getAttribute("headingRows")||0;if(a&&("down"==t&&o+s===a||"up"==t&&o===a))return null;const l=parseInt(e.getAttribute("rowspan")||"1"),c="down"==t?o+l:o,u=[...new Iw(i,{endRow:c})],d=u.find((t=>t.cell===e)),h=d.column,p=u.find((({row:e,cellHeight:n,column:r})=>r===h&&("down"==t?e===c:c===e+n)));return p&&p.cell?p.cell:null}(n,this.direction,t);if(!r)return;const i=this.isHorizontal?"rowspan":"colspan",o=parseInt(n.getAttribute(i)||"1");return parseInt(r.getAttribute(i)||"1")===o?r:void 0}}function ik(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}class ok extends Gi{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const r=n.findAncestor("table"),i=e.getRows(r)-1,o=e.getRowIndexes(t),s=0===o.first&&o.last===i;this.isEnabled=!s}else this.isEnabled=!1}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),n=t.getSelectionAffectedTableCells(e.document.selection),r=t.getRowIndexes(n),i=n[0],o=i.findAncestor("table"),s=t.getCellLocation(i).column;e.change((e=>{const n=r.last-r.first+1;t.removeRows(o,{at:r.first,rows:n});const i=function(e,t,n,r){const i=e.getChild(Math.min(t,r-1));let o=i.getChild(0),s=0;for(const e of i.getChildren()){if(s>n)return o;o=e,s+=parseInt(e.getAttribute("colspan")||"1")}return o}(o,r.first,s,t.getRows(o));e.setSelection(e.createPositionAt(i,0))}))}}class sk extends Gi{refresh(){const e=this.editor.plugins.get("TableUtils"),t=e.getSelectionAffectedTableCells(this.editor.model.document.selection),n=t[0];if(n){const r=n.findAncestor("table"),i=e.getColumns(r),{first:o,last:s}=e.getColumnIndexes(t);this.isEnabled=s-oe.cell===t)).column,last:i.find((e=>e.cell===n)).column},s=function(e,t,n,r){return parseInt(n.getAttribute("colspan")||"1")>1?n:t.previousSibling||n.nextSibling?n.nextSibling||t.previousSibling:r.first?e.reverse().find((({column:e})=>ee>r.last)).cell}(i,t,n,o);this.editor.model.change((t=>{const n=o.last-o.first+1;e.removeColumns(r,{at:o.first,columns:n}),t.setSelection(t.createPositionAt(s,0))}))}}class ak extends Gi{refresh(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection),r=n.length>0;this.isEnabled=r,this.value=r&&n.every((e=>this._isInHeading(e,e.parent.parent)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,r=t.getSelectionAffectedTableCells(n.document.selection),i=r[0].findAncestor("table"),{first:o,last:s}=t.getRowIndexes(r),a=this.value?o:s+1,l=i.getAttribute("headingRows")||0;n.change((e=>{if(a){const t=qw(i,a,a>l?l:0);for(const{cell:n}of t)Zw(n,a,e)}Dw("headingRows",a,i,e,0)}))}_isInHeading(e,t){const n=parseInt(t.getAttribute("headingRows")||"0");return!!n&&e.parent.index0;this.isEnabled=r,this.value=r&&n.every((e=>Ow(t,e)))}execute(e={}){if(e.forceValue===this.value)return;const t=this.editor.plugins.get("TableUtils"),n=this.editor.model,r=t.getSelectionAffectedTableCells(n.document.selection),i=r[0].findAncestor("table"),{first:o,last:s}=t.getColumnIndexes(r),a=this.value?o:s+1;n.change((e=>{if(a){const t=Gw(i,a);for(const{cell:n,column:r}of t)Kw(n,r,a,e)}Dw("headingColumns",a,i,e,0)}))}}class ck extends qi{static get pluginName(){return"TableUtils"}init(){this.decorate("insertColumns"),this.decorate("insertRows")}getCellLocation(e){const t=e.parent,n=t.parent,r=n.getChildIndex(t),i=new Iw(n,{row:r});for(const{cell:t,row:n,column:r}of i)if(t===e)return{row:n,column:r}}createTable(e,t){const n=e.createElement("table"),r=t.rows||2,i=t.columns||2;return uk(e,n,0,r,i),t.headingRows&&Dw("headingRows",Math.min(t.headingRows,r),n,e,0),t.headingColumns&&Dw("headingColumns",Math.min(t.headingColumns,i),n,e,0),n}insertRows(e,t={}){const n=this.editor.model,r=t.at||0,i=t.rows||1,o=void 0!==t.copyStructureFromAbove,s=t.copyStructureFromAbove?r-1:r,a=this.getRows(e),l=this.getColumns(e);if(r>a)throw new k("tableutils-insertrows-insert-out-of-range",this,{options:t});n.change((t=>{const n=e.getAttribute("headingRows")||0;if(n>r&&Dw("headingRows",n+i,e,t,0),!o&&(0===r||r===a))return void uk(t,e,r,i,l);const c=o?Math.max(r,s):r,u=new Iw(e,{endRow:c}),d=new Array(l).fill(1);for(const{row:e,column:n,cellHeight:a,cellWidth:l,cell:c}of u){const u=e+a-1,h=e<=s&&s<=u;e0&&Tw(t,i,r>1?{colspan:r}:void 0),e+=Math.abs(r)-1}}}))}insertColumns(e,t={}){const n=this.editor.model,r=t.at||0,i=t.columns||1;n.change((t=>{const n=e.getAttribute("headingColumns");ri-1)throw new k("tableutils-removerows-row-index-out-of-range",this,{table:e,options:t});n.change((t=>{const n={first:o,last:s},{cellsToMove:r,cellsToTrim:i}=function(e,{first:t,last:n}){const r=new Map,i=[];for(const{row:o,column:s,cellHeight:a,cell:l}of new Iw(e,{endRow:n})){const e=o+a-1;if(o>=t&&o<=n&&e>n){const e=a-(n-o+1);r.set(s,{cell:l,rowspan:e})}if(o=t){let r;r=e>=n?n-t+1:e-t+1,i.push({cell:l,rowspan:a-r})}}return{cellsToMove:r,cellsToTrim:i}}(e,n);r.size&&function(e,t,n,r){const i=[...new Iw(e,{includeAllSlots:!0,row:t})],o=e.getChild(t);let s;for(const{column:e,cell:t,isAnchor:a}of i)if(n.has(e)){const{cell:t,rowspan:i}=n.get(e),a=s?r.createPositionAfter(s):r.createPositionAt(o,0);r.move(r.createRangeOn(t),a),Dw("rowspan",i,t,r),s=t}else a&&(s=t)}(e,s+1,r,t);for(let n=s;n>=o;n--)t.remove(e.getChild(n));for(const{rowspan:e,cell:n}of i)Dw("rowspan",e,n,t);!function(e,{first:t,last:n},r){const i=e.getAttribute("headingRows")||0;t{!function(e,t,n){const r=e.getAttribute("headingColumns")||0;if(r&&t.first=r;n--)for(const{cell:r,column:i,cellWidth:o}of[...new Iw(e)])i<=n&&o>1&&i+o>n?Dw("colspan",o-1,r,t):i===n&&t.remove(r);Xw(e,this)||Jw(e,this)}))}splitCellVertically(e,t=2){const n=this.editor.model,r=e.parent.parent,i=parseInt(e.getAttribute("rowspan")||"1"),o=parseInt(e.getAttribute("colspan")||"1");n.change((n=>{if(o>1){const{newCellsSpan:r,updatedSpan:s}=hk(o,t);Dw("colspan",s,e,n);const a={};r>1&&(a.colspan=r),i>1&&(a.rowspan=i),dk(o>t?t-1:o-1,n,n.createPositionAfter(e),a)}if(ot===e)),c=a.filter((({cell:t,cellWidth:n,column:r})=>t!==e&&r===l||rl));for(const{cell:e,cellWidth:t}of c)n.setAttribute("colspan",t+s,e);const u={};i>1&&(u.rowspan=i),dk(s,n,n.createPositionAfter(e),u);const d=r.getAttribute("headingColumns")||0;d>l&&Dw("headingColumns",d+s,r,n)}}))}splitCellHorizontally(e,t=2){const n=this.editor.model,r=e.parent,i=r.parent,o=i.getChildIndex(r),s=parseInt(e.getAttribute("rowspan")||"1"),a=parseInt(e.getAttribute("colspan")||"1");n.change((n=>{if(s>1){const r=[...new Iw(i,{startRow:o,endRow:o+s-1,includeAllSlots:!0})],{newCellsSpan:l,updatedSpan:c}=hk(s,t);Dw("rowspan",c,e,n);const{column:u}=r.find((({cell:t})=>t===e)),d={};l>1&&(d.rowspan=l),a>1&&(d.colspan=a);for(const e of r){const{column:t,row:r}=e;r>=o+c&&t===u&&(r+o+c)%l==0&&dk(1,n,e.getPositionBefore(),d)}}if(so){const e=i+r;n.setAttribute("rowspan",e,t)}const c={};a>1&&(c.colspan=a),uk(n,i,o+1,r,1,c);const u=i.getAttribute("headingRows")||0;u>o&&Dw("headingRows",u+r,i,n)}}))}getColumns(e){return[...e.getChild(0).getChildren()].reduce(((e,t)=>e+parseInt(t.getAttribute("colspan")||"1")),0)}getRows(e){return Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0)}createTableWalker(e,t={}){return new Iw(e,t)}getSelectedTableCells(e){const t=[];for(const n of this.sortRanges(e.getRanges())){const e=n.getContainedElement();e&&e.is("element","tableCell")&&t.push(e)}return t}getTableCellsContainingSelection(e){const t=[];for(const n of e.getRanges()){const e=n.start.findAncestor("tableCell");e&&t.push(e)}return t}getSelectionAffectedTableCells(e){const t=this.getSelectedTableCells(e);return t.length?t:this.getTableCellsContainingSelection(e)}getRowIndexes(e){const t=e.map((e=>e.parent.index));return this._getFirstLastIndexesObject(t)}getColumnIndexes(e){const t=e[0].findAncestor("table"),n=[...new Iw(t)].filter((t=>e.includes(t.cell))).map((e=>e.column));return this._getFirstLastIndexesObject(n)}isSelectionRectangular(e){if(e.length<2||!this._areCellInTheSameTableSection(e))return!1;const t=new Set,n=new Set;let r=0;for(const i of e){const{row:e,column:o}=this.getCellLocation(i),s=parseInt(i.getAttribute("rowspan"))||1,a=parseInt(i.getAttribute("colspan"))||1;t.add(e),n.add(o),s>1&&t.add(e+s-1),a>1&&n.add(o+a-1),r+=s*a}const i=function(e,t){const n=Array.from(e.values()),r=Array.from(t.values());return(Math.max(...n)-Math.min(...n)+1)*(Math.max(...r)-Math.min(...r)+1)}(t,n);return i==r}sortRanges(e){return Array.from(e).sort(pk)}_getFirstLastIndexesObject(e){const t=e.sort(((e,t)=>e-t));return{first:t[0],last:t[t.length-1]}}_areCellInTheSameTableSection(e){const t=e[0].findAncestor("table"),n=this.getRowIndexes(e),r=parseInt(t.getAttribute("headingRows"))||0;if(!this._areIndexesInSameSection(n,r))return!1;const i=this.getColumnIndexes(e),o=parseInt(t.getAttribute("headingColumns"))||0;return this._areIndexesInSameSection(i,o)}_areIndexesInSameSection({first:e,last:t},n){return e{const r=t.getSelectedTableCells(e.document.selection),i=r.shift(),{mergeWidth:o,mergeHeight:s}=function(e,t,n){let r=0,i=0;for(const e of t){const{row:t,column:o}=n.getCellLocation(e);r=bk(e,o,r,"colspan"),i=bk(e,t,i,"rowspan")}const{row:o,column:s}=n.getCellLocation(e);return{mergeWidth:r-s,mergeHeight:i-o}}(i,r,t);Dw("colspan",o,i,n),Dw("rowspan",s,i,n);for(const e of r)mk(e,i,n);ek(i.findAncestor("table"),t),n.setSelection(i,"in")}))}}function mk(e,t,n){gk(e)||(gk(t)&&n.remove(n.createRangeIn(t)),n.move(n.createRangeIn(e),n.createPositionAt(t,"end"))),n.remove(e)}function gk(e){const t=e.getChild(0);return 1==e.childCount&&t.is("element","paragraph")&&t.isEmpty}function bk(e,t,n,r){const i=parseInt(e.getAttribute(r)||"1");return Math.max(n,t+i)}class yk extends Gi{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.model,t=this.editor.plugins.get("TableUtils"),n=t.getSelectionAffectedTableCells(e.document.selection),r=t.getRowIndexes(n),i=n[0].findAncestor("table"),o=[];for(let t=r.first;t<=r.last;t++)for(const n of i.getChild(t).getChildren())o.push(e.createRangeOn(n));e.change((e=>{e.setSelection(o)}))}}class vk extends Gi{constructor(e){super(e),this.affectsData=!1}refresh(){const e=this.editor.plugins.get("TableUtils").getSelectionAffectedTableCells(this.editor.model.document.selection);this.isEnabled=e.length>0}execute(){const e=this.editor.plugins.get("TableUtils"),t=this.editor.model,n=e.getSelectionAffectedTableCells(t.document.selection),r=n[0],i=n.pop(),o=r.findAncestor("table"),s=e.getCellLocation(r),a=e.getCellLocation(i),l=Math.min(s.column,a.column),c=Math.max(s.column,a.column),u=[];for(const e of new Iw(o,{startColumn:l,endColumn:c}))u.push(t.createRangeOn(e.cell));t.change((e=>{e.setSelection(u)}))}}function _k(e,t){let n=!1;const r=function(e){const t=parseInt(e.getAttribute("headingRows")||"0"),n=Array.from(e.getChildren()).reduce(((e,t)=>t.is("element","tableRow")?e+1:e),0),r=[];for(const{row:i,cell:o,cellHeight:s}of new Iw(e)){if(s<2)continue;const e=ie){const t=e-i;r.push({cell:o,rowspan:t})}}return r}(e);if(r.length){n=!0;for(const e of r)Dw("rowspan",e.rowspan,e.cell,t,1)}return n}function wk(e,t){let n=!1;const r=function(e){const t=new Array(e.childCount).fill(0);for(const{rowIndex:n}of new Iw(e,{includeAllSlots:!0}))t[n]++;return t}(e),i=[];for(const[t,n]of r.entries())!n&&e.getChild(t).is("element","tableRow")&&i.push(t);if(i.length){n=!0;for(const n of i.reverse())t.remove(e.getChild(n)),r.splice(n,1)}const o=r.filter(((t,n)=>e.getChild(n).is("element","tableRow"))),s=o[0];if(!o.every((e=>e===s))){const r=o.reduce(((e,t)=>t>e?t:e),0);for(const[i,s]of o.entries()){const o=r-s;if(o){for(let n=0;ne.is("$text")));for(const e of n)t.wrap(t.createRangeOn(e),"paragraph");return!!n.length}function Ak(e){return!!e.position.parent.is("element","tableCell")&&("insert"==e.type&&"$text"==e.name||"remove"==e.type)}function Sk(e,t){if(!e.is("element","paragraph"))return!1;const n=t.toViewElement(e);return!!n&&Yw(e)!==n.is("element","span")}var Mk=o(3881);Kr()(Mk.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Mk.Z.locals;class Nk extends qi{constructor(e){super(e),this._additionalSlots=[]}static get pluginName(){return"TableEditing"}static get requires(){return[ck]}init(){const e=this.editor,t=e.model,n=t.schema,r=e.conversion,i=e.plugins.get(ck);n.register("table",{inheritAllFrom:"$blockObject",allowAttributes:["headingRows","headingColumns"]}),n.register("tableRow",{allowIn:"table",isLimit:!0}),n.register("tableCell",{allowContentOf:"$container",allowIn:"tableRow",allowAttributes:["colspan","rowspan"],isLimit:!0,isSelectable:!0}),r.for("upcast").add((e=>{e.on("element:figure",((e,t,n)=>{if(!n.consumable.test(t.viewItem,{name:!0,classes:"table"}))return;const r=function(e){for(const t of e.getChildren())if(t.is("element","table"))return t}(t.viewItem);if(!r||!n.consumable.test(r,{name:!0}))return;n.consumable.consume(t.viewItem,{name:!0,classes:"table"});const i=Br(n.convertItem(r,t.modelCursor).modelRange.getItems());i?(n.convertChildren(t.viewItem,n.writer.createPositionAt(i,"end")),n.updateConversionResult(i,t)):n.consumable.revert(t.viewItem,{name:!0,classes:"table"})}))})),r.for("upcast").add((e=>{e.on("element:table",((e,t,n)=>{const r=t.viewItem;if(!n.consumable.test(r,{name:!0}))return;const{rows:i,headingRows:o,headingColumns:s}=function(e){let t,n=0;const r=[],i=[];let o;for(const s of Array.from(e.getChildren())){if("tbody"!==s.name&&"thead"!==s.name&&"tfoot"!==s.name)continue;"thead"!==s.name||o||(o=s);const e=Array.from(s.getChildren()).filter((e=>e.is("element","tr")));for(const a of e)if(o&&s===o||"tbody"===s.name&&Array.from(a.getChildren()).length&&Array.from(a.getChildren()).every((e=>e.is("element","th"))))n++,r.push(a);else{i.push(a);const e=Pw(a);(!t||en.convertItem(e,n.writer.createPositionAt(l,"end")))),n.convertChildren(r,n.writer.createPositionAt(l,"end")),l.isEmpty){const e=n.writer.createElement("tableRow");n.writer.insert(e,n.writer.createPositionAt(l,"end")),Tw(n.writer,n.writer.createPositionAt(e,"end"))}n.updateConversionResult(l,t)}}))})),r.for("editingDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Rw(i,{asWidget:!0,additionalSlots:this._additionalSlots})}),r.for("dataDowncast").elementToStructure({model:{name:"table",attributes:["headingRows"]},view:Rw(i,{additionalSlots:this._additionalSlots})}),r.for("upcast").elementToElement({model:"tableRow",view:"tr"}),r.for("upcast").add((e=>{e.on("element:tr",((e,t)=>{t.viewItem.isEmpty&&0==t.modelCursor.index&&e.stop()}),{priority:"high"})})),r.for("downcast").elementToElement({model:"tableRow",view:(e,{writer:t})=>e.isEmpty?t.createEmptyElement("tr"):t.createContainerElement("tr")}),r.for("upcast").elementToElement({model:"tableCell",view:"td"}),r.for("upcast").elementToElement({model:"tableCell",view:"th"}),r.for("upcast").add(Lw("td")),r.for("upcast").add(Lw("th")),r.for("editingDowncast").elementToElement({model:"tableCell",view:Bw({asWidget:!0})}),r.for("dataDowncast").elementToElement({model:"tableCell",view:Bw()}),r.for("editingDowncast").elementToElement({model:"paragraph",view:Fw({asWidget:!0}),converterPriority:"high"}),r.for("dataDowncast").elementToElement({model:"paragraph",view:Fw(),converterPriority:"high"}),r.for("downcast").attributeToAttribute({model:"colspan",view:"colspan"}),r.for("upcast").attributeToAttribute({model:{key:"colspan",value:Ek("colspan")},view:"colspan"}),r.for("downcast").attributeToAttribute({model:"rowspan",view:"rowspan"}),r.for("upcast").attributeToAttribute({model:{key:"rowspan",value:Ek("rowspan")},view:"rowspan"}),e.config.define("table.defaultHeadings.rows",0),e.config.define("table.defaultHeadings.columns",0),e.commands.add("insertTable",new Hw(e)),e.commands.add("insertTableRowAbove",new $w(e,{order:"above"})),e.commands.add("insertTableRowBelow",new $w(e,{order:"below"})),e.commands.add("insertTableColumnLeft",new Uw(e,{order:"left"})),e.commands.add("insertTableColumnRight",new Uw(e,{order:"right"})),e.commands.add("removeTableRow",new ok(e)),e.commands.add("removeTableColumn",new sk(e)),e.commands.add("splitTableCellVertically",new Ww(e,{direction:"vertically"})),e.commands.add("splitTableCellHorizontally",new Ww(e,{direction:"horizontally"})),e.commands.add("mergeTableCells",new fk(e)),e.commands.add("mergeTableCellRight",new rk(e,{direction:"right"})),e.commands.add("mergeTableCellLeft",new rk(e,{direction:"left"})),e.commands.add("mergeTableCellDown",new rk(e,{direction:"down"})),e.commands.add("mergeTableCellUp",new rk(e,{direction:"up"})),e.commands.add("setTableColumnHeader",new lk(e)),e.commands.add("setTableRowHeader",new ak(e)),e.commands.add("selectTableRow",new yk(e)),e.commands.add("selectTableColumn",new vk(e)),function(e){e.document.registerPostFixer((t=>function(e,t){const n=t.document.differ.getChanges();let r=!1;const i=new Set;for(const t of n){let n=null;"insert"==t.type&&"table"==t.name&&(n=t.position.nodeAfter),"insert"!=t.type&&"remove"!=t.type||"tableRow"!=t.name&&"tableCell"!=t.name||(n=t.position.findAncestor("table")),kk(t)&&(n=t.range.start.findAncestor("table")),n&&!i.has(n)&&(r=_k(n,e)||r,r=wk(n,e)||r,i.add(n))}return r}(t,e)))}(t),function(e){e.document.registerPostFixer((t=>function(e,t){const n=t.document.differ.getChanges();let r=!1;for(const t of n)"insert"==t.type&&"table"==t.name&&(r=xk(t.position.nodeAfter,e)||r),"insert"==t.type&&"tableRow"==t.name&&(r=Ck(t.position.nodeAfter,e)||r),"insert"==t.type&&"tableCell"==t.name&&(r=jk(t.position.nodeAfter,e)||r),"remove"!=t.type&&"insert"!=t.type||!Ak(t)||(r=jk(t.position.parent,e)||r);return r}(t,e)))}(t),this.listenTo(t.document,"change:data",(()=>{!function(e,t){const n=e.document.differ;for(const e of n.getChanges()){let n,r=!1;if("attribute"==e.type){const t=e.range.start.nodeAfter;if(!t||!t.is("element","table"))continue;if("headingRows"!=e.attributeKey&&"headingColumns"!=e.attributeKey)continue;n=t,r="headingRows"==e.attributeKey}else"tableRow"!=e.name&&"tableCell"!=e.name||(n=e.position.findAncestor("table"),r="tableRow"==e.name);if(!n)continue;const i=n.getAttribute("headingRows")||0,o=n.getAttribute("headingColumns")||0,s=new Iw(n);for(const e of s){const n=e.rowSk(e,t.mapper)));for(const e of n)t.reconvertItem(e)}}(t,e.editing)}))}registerAdditionalSlot(e){this._additionalSlots.push(e)}}function Ek(e){return t=>{const n=parseInt(t.getAttribute(e));return Number.isNaN(n)||n<=0?null:n}}var Dk=o(1613);Kr()(Dk.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Dk.Z.locals;class Tk extends Jr{constructor(e){super(e);const t=this.bindTemplate;this.items=this._createGridCollection(),this.keystrokes=new Yr,this.focusTracker=new Fr,this.set("rows",0),this.set("columns",0),this.bind("label").to(this,"columns",this,"rows",((e,t)=>`${t} × ${e}`)),this.setTemplate({tag:"div",attributes:{class:["ck"]},children:[{tag:"div",attributes:{class:["ck-insert-table-dropdown__grid"]},on:{"mouseover@.ck-insert-table-dropdown-grid-box":t.to("boxover")},children:this.items},{tag:"div",attributes:{class:["ck","ck-insert-table-dropdown__label"],"aria-hidden":!0},children:[{text:t.to("label")}]}],on:{mousedown:t.to((e=>{e.preventDefault()})),click:t.to((()=>{this.fire("execute")}))}}),this.on("boxover",((e,t)=>{const{row:n,column:r}=t.target.dataset;this.items.get(10*(parseInt(n,10)-1)+(parseInt(r,10)-1)).focus()})),this.focusTracker.on("change:focusedElement",((e,t,n)=>{if(!n)return;const{row:r,column:i}=n.dataset;this.set({rows:parseInt(r),columns:parseInt(i)})})),this.on("change:columns",(()=>this._highlightGridBoxes())),this.on("change:rows",(()=>this._highlightGridBoxes()))}render(){super.render(),function({keystrokeHandler:e,focusTracker:t,gridItems:n,numberOfColumns:r,uiLanguageDirection:i}){const o="number"==typeof r?()=>r:r;function s(e){return r=>{const i=n.find((e=>e.element===t.focusedElement)),o=n.getIndex(i),s=e(o,n);n.get(s).focus(),r.stopPropagation(),r.preventDefault()}}function a(e,t){return e===t-1?0:e+1}function l(e,t){return 0===e?t-1:e-1}e.set("arrowright",s(((e,t)=>"rtl"===i?l(e,t.length):a(e,t.length)))),e.set("arrowleft",s(((e,t)=>"rtl"===i?a(e,t.length):l(e,t.length)))),e.set("arrowup",s(((e,t)=>{let n=e-o();return n<0&&(n=e+o()*Math.floor(t.length/o()),n>t.length-1&&(n-=o())),n}))),e.set("arrowdown",s(((e,t)=>{let n=e+o();return n>t.length-1&&(n=e%o()),n})))}({keystrokeHandler:this.keystrokes,focusTracker:this.focusTracker,gridItems:this.items,numberOfColumns:10,uiLanguageDirection:this.locale&&this.locale.uiLanguageDirection});for(const e of this.items)this.focusTracker.add(e.element);this.keystrokes.listenTo(this.element)}focus(){this.items.get(0).focus()}focusLast(){this.items.get(0).focus()}_highlightGridBoxes(){const e=this.rows,t=this.columns;this.items.map(((n,r)=>{const i=Math.floor(r/10){const r=e.commands.get("insertTable"),i=yh(n);let o;return i.bind("isEnabled").to(r),i.buttonView.set({icon:'',label:t("Insert table"),tooltip:!0}),i.on("change:isOpen",(()=>{o||(o=new Tk(n),i.panelView.children.add(o),o.delegate("execute").to(i),i.on("execute",(()=>{e.execute("insertTable",{rows:o.rows,columns:o.columns}),e.editing.view.focus()})))})),i})),e.ui.componentFactory.add("tableColumn",(e=>{const r=[{type:"switchbutton",model:{commandName:"setTableColumnHeader",label:t("Header column"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:n?"insertTableColumnLeft":"insertTableColumnRight",label:t("Insert column left")}},{type:"button",model:{commandName:n?"insertTableColumnRight":"insertTableColumnLeft",label:t("Insert column right")}},{type:"button",model:{commandName:"removeTableColumn",label:t("Delete column")}},{type:"button",model:{commandName:"selectTableColumn",label:t("Select column")}}];return this._prepareDropdown(t("Column"),'',r,e)})),e.ui.componentFactory.add("tableRow",(e=>{const n=[{type:"switchbutton",model:{commandName:"setTableRowHeader",label:t("Header row"),bindIsOn:!0}},{type:"separator"},{type:"button",model:{commandName:"insertTableRowAbove",label:t("Insert row above")}},{type:"button",model:{commandName:"insertTableRowBelow",label:t("Insert row below")}},{type:"button",model:{commandName:"removeTableRow",label:t("Delete row")}},{type:"button",model:{commandName:"selectTableRow",label:t("Select row")}}];return this._prepareDropdown(t("Row"),'',n,e)})),e.ui.componentFactory.add("mergeTableCells",(e=>{const r=[{type:"button",model:{commandName:"mergeTableCellUp",label:t("Merge cell up")}},{type:"button",model:{commandName:n?"mergeTableCellRight":"mergeTableCellLeft",label:t("Merge cell right")}},{type:"button",model:{commandName:"mergeTableCellDown",label:t("Merge cell down")}},{type:"button",model:{commandName:n?"mergeTableCellLeft":"mergeTableCellRight",label:t("Merge cell left")}},{type:"separator"},{type:"button",model:{commandName:"splitTableCellVertically",label:t("Split cell vertically")}},{type:"button",model:{commandName:"splitTableCellHorizontally",label:t("Split cell horizontally")}}];return this._prepareMergeSplitButtonDropdown(t("Merge cells"),'',r,e)}))}_prepareDropdown(e,t,n,r){const i=this.editor,o=yh(r),s=this._fillDropdownWithListOptions(o,n);return o.buttonView.set({label:e,icon:t,tooltip:!0}),o.bind("isEnabled").toMany(s,"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(o,"execute",(e=>{i.execute(e.source.commandName),e.source instanceof Si||i.editing.view.focus()})),o}_prepareMergeSplitButtonDropdown(e,t,n,r){const i=this.editor,o=yh(r,mh),s="mergeTableCells",a=i.commands.get(s),l=this._fillDropdownWithListOptions(o,n);return o.buttonView.set({label:e,icon:t,tooltip:!0,isEnabled:!0}),o.bind("isEnabled").toMany([a,...l],"isEnabled",((...e)=>e.some((e=>e)))),this.listenTo(o.buttonView,"execute",(()=>{i.execute(s),i.editing.view.focus()})),this.listenTo(o,"execute",(e=>{i.execute(e.source.commandName),i.editing.view.focus()})),o}_fillDropdownWithListOptions(e,t){const n=this.editor,r=[],i=new Rr;for(const e of t)Lk(e,n,r,i);return wh(e,i),r}}function Lk(e,t,n,r){if("button"===e.type||"switchbutton"===e.type){const r=e.model=new Hp(e.model),{commandName:i,bindIsOn:o}=e.model,s=t.commands.get(i);n.push(s),r.set({commandName:i}),r.bind("isEnabled").to(s),o&&r.bind("isOn").to(s,"value"),r.set({withText:!0})}r.add(e)}var Pk=o(6945);Kr()(Pk.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Pk.Z.locals;class Ik extends qi{static get pluginName(){return"TableSelection"}static get requires(){return[ck,ck]}init(){const e=this.editor,t=e.model,n=e.editing.view;this.listenTo(t,"deleteContent",((e,t)=>this._handleDeleteContent(e,t)),{priority:"high"}),this.listenTo(n.document,"insertText",((e,t)=>this._handleInsertTextEvent(e,t)),{priority:"high"}),this._defineSelectionConverter(),this._enablePluginDisabling()}getSelectedTableCells(){const e=this.editor.plugins.get(ck),t=this.editor.model.document.selection,n=e.getSelectedTableCells(t);return 0==n.length?null:n}getSelectionAsFragment(){const e=this.editor.plugins.get(ck),t=this.getSelectedTableCells();return t?this.editor.model.change((n=>{const r=n.createDocumentFragment(),{first:i,last:o}=e.getColumnIndexes(t),{first:s,last:a}=e.getRowIndexes(t),l=t[0].findAncestor("table");let c=a,u=o;if(e.isSelectionRectangular(t)){const e={firstColumn:i,lastColumn:o,firstRow:s,lastRow:a};c=tk(l,e),u=nk(l,e)}const d=Vw(l,{startRow:s,startColumn:i,endRow:c,endColumn:u},n);return n.insert(d,r,0),r})):null}setCellSelection(e,t){const n=this._getCellsToSelect(e,t);this.editor.model.change((e=>{e.setSelection(n.cells.map((t=>e.createRangeOn(t))),{backward:n.backward})}))}getFocusCell(){const e=[...this.editor.model.document.selection.getRanges()].pop().getContainedElement();return e&&e.is("element","tableCell")?e:null}getAnchorCell(){const e=Br(this.editor.model.document.selection.getRanges()).getContainedElement();return e&&e.is("element","tableCell")?e:null}_defineSelectionConverter(){const e=this.editor,t=new Set;e.conversion.for("editingDowncast").add((e=>e.on("selection",((e,n,r)=>{const i=r.writer;!function(e){for(const n of t)e.removeClass("ck-editor__editable_selected",n);t.clear()}(i);const o=this.getSelectedTableCells();if(!o)return;for(const e of o){const n=r.mapper.toViewElement(e);i.addClass("ck-editor__editable_selected",n),t.add(n)}const s=r.mapper.toViewElement(o[o.length-1]);i.setSelection(s,0)}),{priority:"lowest"})))}_enablePluginDisabling(){const e=this.editor;this.on("change:isEnabled",(()=>{if(!this.isEnabled){const t=this.getSelectedTableCells();if(!t)return;e.model.change((n=>{const r=n.createPositionAt(t[0],0),i=e.model.schema.getNearestSelectionRange(r);n.setSelection(i)}))}}))}_handleDeleteContent(e,t){const n=this.editor.plugins.get(ck),r=t[0],i=t[1],o=this.editor.model,s=!i||"backward"==i.direction,a=n.getSelectedTableCells(r);a.length&&(e.stop(),o.change((e=>{const t=a[s?a.length-1:0];o.change((e=>{for(const t of a)o.deleteContent(e.createSelection(t,"in"))}));const n=o.schema.getNearestSelectionRange(e.createPositionAt(t,0));r.is("documentSelection")?e.setSelection(n):r.setTo(n)})))}_handleInsertTextEvent(e,t){const n=this.editor,r=this.getSelectedTableCells();if(!r)return;const i=n.editing.view,o=n.editing.mapper,s=r.map((e=>i.createRangeOn(o.toViewElement(e))));t.selection=i.createSelection(s)}_getCellsToSelect(e,t){const n=this.editor.plugins.get("TableUtils"),r=n.getCellLocation(e),i=n.getCellLocation(t),o=Math.min(r.row,i.row),s=Math.max(r.row,i.row),a=Math.min(r.column,i.column),l=Math.max(r.column,i.column),c=new Array(s-o+1).fill(null).map((()=>[])),u={startRow:o,endRow:s,startColumn:a,endColumn:l};for(const{row:t,cell:n}of new Iw(e.findAncestor("table"),u))c[t-o].push(n);const d=i.rowe.reverse())),{cells:c.flat(),backward:d||h}}}class zk extends qi{static get pluginName(){return"TableClipboard"}static get requires(){return[Ik,ck]}init(){const e=this.editor,t=e.editing.view.document;this.listenTo(t,"copy",((e,t)=>this._onCopyCut(e,t))),this.listenTo(t,"cut",((e,t)=>this._onCopyCut(e,t))),this.listenTo(e.model,"insertContent",((e,[t,n])=>this._onInsertContent(e,t,n)),{priority:"high"}),this.decorate("_replaceTableSlotCell")}_onCopyCut(e,t){const n=this.editor.plugins.get(Ik);if(!n.getSelectedTableCells())return;if("cut"==e.name&&!this.editor.model.canEditAt(this.editor.model.document.selection))return;t.preventDefault(),e.stop();const r=this.editor.data,i=this.editor.editing.view.document,o=r.toView(n.getSelectionAsFragment());i.fire("clipboardOutput",{dataTransfer:t.dataTransfer,content:o,method:e.name})}_onInsertContent(e,t,n){if(n&&!n.is("documentSelection"))return;const r=this.editor.model,i=this.editor.plugins.get(ck);let o=this.getTableIfOnlyTableInContent(t,r);if(!o)return;const s=i.getSelectionAffectedTableCells(r.document.selection);s.length?(e.stop(),r.change((e=>{const t={width:i.getColumns(o),height:i.getRows(o)},n=function(e,t,n,r){const i=e[0].findAncestor("table"),o=r.getColumnIndexes(e),s=r.getRowIndexes(e),a={firstColumn:o.first,lastColumn:o.last,firstRow:s.first,lastRow:s.last},l=1===e.length;return l&&(a.lastRow+=t.height-1,a.lastColumn+=t.width-1,function(e,t,n,r){const i=r.getColumns(e),o=r.getRows(e);n>i&&r.insertColumns(e,{at:i,columns:n-i}),t>o&&r.insertRows(e,{at:o,rows:t-o})}(i,a.lastRow+1,a.lastColumn+1,r)),l||!r.isSelectionRectangular(e)?function(e,t,n){const{firstRow:r,lastRow:i,firstColumn:o,lastColumn:s}=t,a={first:r,last:i},l={first:o,last:s};Bk(e,o,a,n),Bk(e,s+1,a,n),Rk(e,r,l,n),Rk(e,i+1,l,n,r)}(i,a,n):(a.lastRow=tk(i,a),a.lastColumn=nk(i,a)),a}(s,t,e,i),r=n.lastRow-n.firstRow+1,a=n.lastColumn-n.firstColumn+1,l={startRow:0,startColumn:0,endRow:Math.min(r,t.height)-1,endColumn:Math.min(a,t.width)-1};o=Vw(o,l,e);const c=s[0].findAncestor("table"),u=this._replaceSelectedCellsWithPasted(o,t,c,n,e);if(this.editor.plugins.get("TableSelection").isEnabled){const t=i.sortRanges(u.map((t=>e.createRangeOn(t))));e.setSelection(t)}else e.setSelection(u[0],0)}))):ek(o,i)}_replaceSelectedCellsWithPasted(e,t,n,r,i){const{width:o,height:s}=t,a=function(e,t,n){const r=new Array(n).fill(null).map((()=>new Array(t).fill(null)));for(const{column:t,row:n,cell:i}of new Iw(e))r[n][t]=i;return r}(e,o,s),l=[...new Iw(n,{startRow:r.firstRow,endRow:r.lastRow,startColumn:r.firstColumn,endColumn:r.lastColumn,includeAllSlots:!0})],c=[];let u;for(const e of l){const{row:t,column:n}=e;n===r.firstColumn&&(u=e.getPositionBefore());const l=t-r.firstRow,d=n-r.firstColumn,h=a[l%s][d%o],p=h?i.cloneElement(h):null,f=this._replaceTableSlotCell(e,p,u,i);f&&(Qw(f,t,n,r.lastRow,r.lastColumn,i),c.push(f),u=i.createPositionAfter(f))}const d=parseInt(n.getAttribute("headingRows")||"0"),h=parseInt(n.getAttribute("headingColumns")||"0"),p=r.firstRowFk(e,t,n))).map((({cell:e})=>Zw(e,t,r)))}function Bk(e,t,n,r){if(!(t<1))return Gw(e,t).filter((({row:e,cellHeight:t})=>Fk(e,t,n))).map((({cell:e,column:n})=>Kw(e,n,t,r)))}function Fk(e,t,n){const r=e+t-1,{first:i,last:o}=n;return e>=i&&e<=o||e=i}class Yk extends qi{static get pluginName(){return"TableKeyboard"}static get requires(){return[Ik,ck]}init(){const e=this.editor.editing.view.document;this.listenTo(e,"arrowKey",((...e)=>this._onArrowKey(...e)),{context:"table"}),this.listenTo(e,"tab",((...e)=>this._handleTabOnSelectedTable(...e)),{context:"figure"}),this.listenTo(e,"tab",((...e)=>this._handleTab(...e)),{context:["th","td"]})}_handleTabOnSelectedTable(e,t){const n=this.editor,r=n.model.document.selection.getSelectedElement();r&&r.is("element","table")&&(t.preventDefault(),t.stopPropagation(),e.stop(),n.model.change((e=>{e.setSelection(e.createRangeIn(r.getChild(0).getChild(0)))})))}_handleTab(e,t){const n=this.editor,r=this.editor.plugins.get(ck),i=this.editor.plugins.get("TableSelection"),o=n.model.document.selection,s=!t.shiftKey;let a=r.getTableCellsContainingSelection(o)[0];if(a||(a=i.getFocusCell()),!a)return;t.preventDefault(),t.stopPropagation(),e.stop();const l=a.parent,c=l.parent,u=c.getChildIndex(l),d=l.getChildIndex(a),h=0===d;if(!s&&h&&0===u)return void n.model.change((e=>{e.setSelection(e.createRangeOn(c))}));const p=d===l.childCount-1,f=u===r.getRows(c)-1;if(s&&f&&p&&(n.execute("insertTableRowBelow"),u===r.getRows(c)-1))return void n.model.change((e=>{e.setSelection(e.createRangeOn(c))}));let m;if(s&&p){const e=c.getChild(u+1);m=e.getChild(0)}else if(!s&&h){const e=c.getChild(u-1);m=e.getChild(e.childCount-1)}else m=l.getChild(d+(s?1:-1));n.model.change((e=>{e.setSelection(e.createRangeIn(m))}))}_onArrowKey(e,t){const n=this.editor,r=Or(t.keyCode,n.locale.contentLanguageDirection);this._handleArrowKeys(r,t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),e.stop())}_handleArrowKeys(e,t){const n=this.editor.plugins.get(ck),r=this.editor.plugins.get("TableSelection"),i=this.editor.model,o=i.document.selection,s=["right","down"].includes(e),a=n.getSelectedTableCells(o);if(a.length){let n;return n=t?r.getFocusCell():s?a[a.length-1]:a[0],this._navigateFromCellInDirection(n,e,t),!0}const l=o.focus.findAncestor("tableCell");if(!l)return!1;if(!o.isCollapsed)if(t){if(o.isBackward==s&&!o.containsEntireContent(l))return!1}else{const e=o.getSelectedElement();if(!e||!i.schema.isObject(e))return!1}return!!this._isSelectionAtCellEdge(o,l,s)&&(this._navigateFromCellInDirection(l,e,t),!0)}_isSelectionAtCellEdge(e,t,n){const r=this.editor.model,i=this.editor.model.schema,o=n?e.getLastPosition():e.getFirstPosition();if(!i.getLimitElement(o).is("element","tableCell"))return r.createPositionAt(t,n?"end":0).isTouching(o);const s=r.createSelection(o);return r.modifySelection(s,{direction:n?"forward":"backward"}),o.isEqual(s.focus)}_navigateFromCellInDirection(e,t,n=!1){const r=this.editor.model,i=e.findAncestor("table"),o=[...new Iw(i,{includeAllSlots:!0})],{row:s,column:a}=o[o.length-1],l=o.find((({cell:t})=>t==e));let{row:c,column:u}=l;switch(t){case"left":u--;break;case"up":c--;break;case"right":u+=l.cellWidth;break;case"down":c+=l.cellHeight}if(c<0||c>s||u<0&&c<=0||u>a&&c>=s)return void r.change((e=>{e.setSelection(e.createRangeOn(i))}));u<0?(u=n?0:a,c--):u>a&&(u=n?a:0,c++);const d=o.find((e=>e.row==c&&e.column==u)).cell,h=["right","down"].includes(t),p=this.editor.plugins.get("TableSelection");if(n&&p.isEnabled){const t=p.getAnchorCell()||e;p.setCellSelection(t,d)}else{const e=r.createPositionAt(d,h?0:"end");r.change((t=>{t.setSelection(e)}))}}}class Hk extends ba{constructor(){super(...arguments),this.domEventType=["mousemove","mouseleave"]}onDomEvent(e){this.fire(e.type,e)}}class $k extends qi{static get pluginName(){return"TableMouse"}static get requires(){return[Ik,ck]}init(){this.editor.editing.view.addObserver(Hk),this._enableShiftClickSelection(),this._enableMouseDragSelection()}_enableShiftClickSelection(){const e=this.editor,t=e.plugins.get(ck);let n=!1;const r=e.plugins.get(Ik);this.listenTo(e.editing.view.document,"mousedown",((i,o)=>{const s=e.model.document.selection;if(!this.isEnabled||!r.isEnabled)return;if(!o.domEvent.shiftKey)return;const a=r.getAnchorCell()||t.getTableCellsContainingSelection(s)[0];if(!a)return;const l=this._getModelTableCellFromDomEvent(o);l&&Uk(a,l)&&(n=!0,r.setCellSelection(a,l),o.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{n=!1})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{n&&e.stop()}),{priority:"highest"})}_enableMouseDragSelection(){const e=this.editor;let t,n,r=!1,i=!1;const o=e.plugins.get(Ik);this.listenTo(e.editing.view.document,"mousedown",((e,n)=>{this.isEnabled&&o.isEnabled&&(n.domEvent.shiftKey||n.domEvent.ctrlKey||n.domEvent.altKey||(t=this._getModelTableCellFromDomEvent(n)))})),this.listenTo(e.editing.view.document,"mousemove",((e,s)=>{if(!s.domEvent.buttons)return;if(!t)return;const a=this._getModelTableCellFromDomEvent(s);a&&Uk(t,a)&&(n=a,r||n==t||(r=!0)),r&&(i=!0,o.setCellSelection(t,n),s.preventDefault())})),this.listenTo(e.editing.view.document,"mouseup",(()=>{r=!1,i=!1,t=null,n=null})),this.listenTo(e.editing.view.document,"selectionChange",(e=>{i&&e.stop()}),{priority:"highest"})}_getModelTableCellFromDomEvent(e){const t=e.target,n=this.editor.editing.view.createPositionAt(t,0);return this.editor.editing.mapper.toModelPosition(n).parent.findAncestor("tableCell",{includeSelf:!0})}}function Uk(e,t){return e.parent.parent==t.parent.parent}var Wk=o(6306);function Vk(e){const t=e.getSelectedElement();return t&&Zk(t)?t:null}function qk(e){const t=e.getFirstPosition();if(!t)return null;let n=t.parent;for(;n;){if(n.is("element")&&Zk(n))return n;n=n.parent}return null}function Zk(e){return!!e.getCustomProperty("table")&&fm(e)}Kr()(Wk.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Wk.Z.locals;var Gk=o(7368);Kr()(Gk.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Gk.Z.locals;var Kk=o(9247);Kr()(Kk.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Kk.Z.locals;var Qk=o(4070);Kr()(Qk.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Qk.Z.locals;var Jk=o(6237);Kr()(Jk.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Jk.Z.locals;var Xk=o(5087);Kr()(Xk.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),Xk.Z.locals;const ex=cp.defaultPositions;ex.northArrowSouth,ex.northArrowSouthWest,ex.northArrowSouthEast,ex.southArrowNorth,ex.southArrowNorthWest,ex.southArrowNorthEast,ex.viewportStickyNorth,Object.defineProperty,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable,Object.defineProperty,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;var tx=o(7341);Kr()(tx.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),tx.Z.locals;var nx=o(2128);Kr()(nx.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),nx.Z.locals;var rx=o(4101);Kr()(rx.Z,{injectType:"singletonStyleTag",attributes:{"data-cke":!0},insert:"head",singleton:!0}),rx.Z.locals;var ix=Object.defineProperty,ox=Object.getOwnPropertySymbols,sx=Object.prototype.hasOwnProperty,ax=Object.prototype.propertyIsEnumerable,lx=(e,t,n)=>t in e?ix(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cx=(e,t)=>{for(var n in t||(t={}))sx.call(t,n)&&lx(e,n,t[n]);if(ox)for(var n of ox(t))ax.call(t,n)&&lx(e,n,t[n]);return e};const ux={autoRefresh:!0},dx=36e5;class hx extends(Z()){constructor(e,t={}){if(super(),!e)throw new k("token-missing-token-url",this);t.initValue&&this._validateTokenValue(t.initValue),this.set("value",t.initValue),this._refresh="function"==typeof e?e:()=>{return t=e,new Promise(((e,n)=>{const r=new XMLHttpRequest;r.open("GET",t),r.addEventListener("load",(()=>{const t=r.status,i=r.response;return t<200||t>299?n(new k("token-cannot-download-new-token",null)):e(i)})),r.addEventListener("error",(()=>n(new Error("Network Error")))),r.addEventListener("abort",(()=>n(new Error("Abort")))),r.send()}));var t},this._options=cx(cx({},ux),t)}init(){return new Promise(((e,t)=>{this.value?(this._options.autoRefresh&&this._registerRefreshTokenTimeout(),e(this)):this.refreshToken().then(e).catch(t)}))}refreshToken(){return this._refresh().then((e=>(this._validateTokenValue(e),this.set("value",e),this._options.autoRefresh&&this._registerRefreshTokenTimeout(),this)))}destroy(){clearTimeout(this._tokenRefreshTimeout)}_validateTokenValue(e){const t="string"==typeof e,n=!/^".*"$/.test(e),r=t&&3===e.split(".").length;if(!n||!r)throw new k("token-not-in-jwt-format",this)}_registerRefreshTokenTimeout(){const e=this._getTokenRefreshTimeoutTime();clearTimeout(this._tokenRefreshTimeout),this._tokenRefreshTimeout=setTimeout((()=>{this.refreshToken()}),e)}_getTokenRefreshTimeoutTime(){try{const[,e]=this.value.split("."),{exp:t}=JSON.parse(atob(e));return t?Math.floor((1e3*t-Date.now())/2):dx}catch(e){return dx}}static create(e,t={}){return new hx(e,t).init()}}const px=/^data:(\S*?);base64,/;class fx extends(O()){constructor(e,t,n){if(super(),!e)throw new k("fileuploader-missing-file",null);if(!t)throw new k("fileuploader-missing-token",null);if(!n)throw new k("fileuploader-missing-api-address",null);this.file=function(e){if("string"!=typeof e)return!1;const t=e.match(px);return!(!t||!t.length)}(e)?function(e,t=512){try{const n=e.match(px)[1],r=atob(e.replace(px,"")),i=[];for(let e=0;ee(n))),this}onError(e){return this.once("error",((t,n)=>e(n))),this}abort(){this.xhr.abort()}send(){return this._prepareRequest(),this._attachXHRListeners(),this._sendRequest()}_prepareRequest(){const e=new XMLHttpRequest;e.open("POST",this._apiAddress),e.setRequestHeader("Authorization",this._token.value),e.responseType="json",this.xhr=e}_attachXHRListeners(){const e=this.xhr,t=e=>()=>this.fire("error",e);e.addEventListener("error",t("Network Error")),e.addEventListener("abort",t("Abort")),e.upload&&e.upload.addEventListener("progress",(e=>{e.lengthComputable&&this.fire("progress",{total:e.total,uploaded:e.loaded})})),e.addEventListener("load",(()=>{const t=e.status,n=e.response;if(t<200||t>299)return this.fire("error",n.message||n.error)}))}_sendRequest(){const e=new FormData,t=this.xhr;return e.append("file",this.file),new Promise(((n,r)=>{t.addEventListener("load",(()=>{const e=t.status,i=t.response;return e<200||e>299?i.message?r(new k("fileuploader-uploading-data-failed",this,{message:i.message})):r(i.error):n(i)})),t.addEventListener("error",(()=>r(new Error("Network Error")))),t.addEventListener("abort",(()=>r(new Error("Abort")))),t.send(e)}))}}class mx{constructor(e,t){if(!e)throw new k("uploadgateway-missing-token",null);if(!t)throw new k("uploadgateway-missing-api-address",null);this._token=e,this._apiAddress=t}upload(e){return new fx(e,this._token,this._apiAddress)}}class gx extends eo{static get pluginName(){return"CloudServicesCore"}createToken(e,t){return new hx(e,t)}createUploadGateway(e,t){return new mx(e,t)}}var bx=(e,t,n)=>new Promise(((r,i)=>{var o=e=>{try{a(n.next(e))}catch(e){i(e)}},s=e=>{try{a(n.throw(e))}catch(e){i(e)}},a=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,s);a((n=n.apply(e,t)).next())}));class yx extends hf{}yx.builtinPlugins=[class extends qi{static get requires(){return[Wm,nm,Qm,sm,Tf,hg]}static get pluginName(){return"Essentials"}},class extends qi{static get requires(){return[fg]}static get pluginName(){return"CKFinderUploadAdapter"}init(){const e=this.editor.config.get("ckfinder.uploadUrl");e&&(this.editor.plugins.get(fg).createUploadAdapter=t=>new _g(t,e,this.editor.t))}},class extends qi{static get requires(){return[Df]}static get pluginName(){return"Autoformat"}afterInit(){this._addListAutoformats(),this._addBasicStylesAutoformats(),this._addHeadingAutoformats(),this._addBlockQuoteAutoformats(),this._addCodeBlockAutoformats(),this._addHorizontalLineAutoformats()}_addListAutoformats(){const e=this.editor.commands;e.get("bulletedList")&&wg(this.editor,this,/^[*-]\s$/,"bulletedList"),e.get("numberedList")&&wg(this.editor,this,/^1[.|)]\s$/,"numberedList"),e.get("todoList")&&wg(this.editor,this,/^\[\s?\]\s$/,"todoList"),e.get("checkTodoList")&&wg(this.editor,this,/^\[\s?x\s?\]\s$/,(()=>{this.editor.execute("todoList"),this.editor.execute("checkTodoList")}))}_addBasicStylesAutoformats(){const e=this.editor.commands;if(e.get("bold")){const e=Cg(this.editor,"bold");kg(this.editor,this,/(?:^|\s)(\*\*)([^*]+)(\*\*)$/g,e),kg(this.editor,this,/(?:^|\s)(__)([^_]+)(__)$/g,e)}if(e.get("italic")){const e=Cg(this.editor,"italic");kg(this.editor,this,/(?:^|\s)(\*)([^*_]+)(\*)$/g,e),kg(this.editor,this,/(?:^|\s)(_)([^_]+)(_)$/g,e)}if(e.get("code")){const e=Cg(this.editor,"code");kg(this.editor,this,/(`)([^`]+)(`)$/g,e)}if(e.get("strikethrough")){const e=Cg(this.editor,"strikethrough");kg(this.editor,this,/(~~)([^~]+)(~~)$/g,e)}}_addHeadingAutoformats(){const e=this.editor.commands.get("heading");e&&e.modelElements.filter((e=>e.match(/^heading[1-6]$/))).forEach((t=>{const n=t[7],r=new RegExp(`^(#{${n}})\\s$`);wg(this.editor,this,r,(()=>{if(!e.isEnabled||e.value===t)return!1;this.editor.execute("heading",{value:t})}))}))}_addBlockQuoteAutoformats(){this.editor.commands.get("blockQuote")&&wg(this.editor,this,/^>\s$/,"blockQuote")}_addCodeBlockAutoformats(){const e=this.editor,t=e.model.document.selection;e.commands.get("codeBlock")&&wg(e,this,/^```$/,(()=>{if(t.getFirstPosition().parent.is("element","listItem"))return!1;this.editor.execute("codeBlock",{usePreviousLanguageChoice:!0})}))}_addHorizontalLineAutoformats(){this.editor.commands.get("horizontalLine")&&wg(this.editor,this,/^---$/,"horizontalLine")}},class extends qi{static get requires(){return[Sg,Ng]}static get pluginName(){return"Bold"}},class extends qi{static get requires(){return[Tg,Lg]}static get pluginName(){return"Italic"}},class extends qi{static get requires(){return[Bg,Yg]}static get pluginName(){return"BlockQuote"}},class extends qi{static get pluginName(){return"CKBox"}static get requires(){return[rb,Hg]}},class extends qi{static get pluginName(){return"CKFinder"}static get requires(){return["Link","CKFinderUploadAdapter",ub,ab]}},class extends eo{constructor(){super(...arguments),this.token=null,this._tokens=new Map}static get pluginName(){return"CloudServices"}static get requires(){return[gx]}init(){return bx(this,null,(function*(){const e=this.context.config.get("cloudServices")||{};for(const[t,n]of Object.entries(e))this[t]=n;if(!this.tokenUrl)return void(this.token=null);const t=this.context.plugins.get("CloudServicesCore");this.token=yield t.createToken(this.tokenUrl).init(),this._tokens.set(this.tokenUrl,this.token)}))}registerTokenUrl(e){return bx(this,null,(function*(){if(this._tokens.has(e))return this.getTokenFor(e);const t=this.context.plugins.get("CloudServicesCore"),n=yield t.createToken(e).init();return this._tokens.set(e,n),n}))}getTokenFor(e){const t=this._tokens.get(e);if(!t)throw new k("cloudservices-token-not-registered",this);return t}destroy(){super.destroy();for(const e of this._tokens.values())e.destroy()}},class extends qi{static get pluginName(){return"EasyImage"}static get requires(){return[db,"ImageUpload"]}init(){const e=this.editor;e.plugins.has("ImageBlockEditing")||e.plugins.has("ImageInlineEditing")||x("easy-image-image-feature-missing",e)}},class extends qi{static get requires(){return[wb,xb]}static get pluginName(){return"Heading"}},class extends qi{static get requires(){return[iy,sy]}static get pluginName(){return"Image"}},class extends qi{static get requires(){return[cy,uy]}static get pluginName(){return"ImageCaption"}},class extends qi{static get requires(){return[iv,sv]}static get pluginName(){return"ImageStyle"}},class extends qi{static get requires(){return[Pm,Ob]}static get pluginName(){return"ImageToolbar"}afterInit(){const e=this.editor,t=e.t,n=e.plugins.get(Pm),r=e.plugins.get("ImageUtils");var i;n.register("image",{ariaLabel:t("Image toolbar"),items:(i=e.config.get("image.toolbar")||[],i.map((e=>Y(e)?e.name:e))),getRelatedElement:e=>r.getClosestSelectedImageWidget(e)})}},class extends qi{static get pluginName(){return"ImageUpload"}static get requires(){return[Oy,my,vy]}},class extends qi{static get pluginName(){return"Indent"}static get requires(){return[uv,pv]}},class extends qi{static get requires(){return[t_,u_,p_]}static get pluginName(){return"Link"}},class extends qi{static get requires(){return[X_,S_]}static get pluginName(){return"List"}},class extends qi{static get requires(){return[uw,mw,hw,Om]}static get pluginName(){return"MediaEmbed"}},bb,class extends qi{static get pluginName(){return"PasteFromOffice"}static get requires(){return[bf]}init(){const e=this.editor,t=e.plugins.get("ClipboardPipeline"),n=e.editing.view.document,r=[];r.push(new xw(n)),r.push(new Sw(n)),r.push(new Nw(n)),t.on("inputTransformation",((t,i)=>{if(i._isTransformedWithPasteFromOffice)return;if(e.model.document.selection.getFirstPosition().parent.is("element","codeBlock"))return;const o=i.dataTransfer.getData("text/html"),s=r.find((e=>e.isActive(o)));s&&(i._parsedData||(i._parsedData=function(e,t){const n=new DOMParser,r=function(e){return Ew(Ew(e)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(e){const t="",n=e.indexOf(t);if(n<0)return e;const r=e.indexOf("