From fa97a5e82224b8e74054c87963c5273fa117ec48 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= 0){if(++e>=ba)return arguments[0]}else e=0;return t.apply(void 0,arguments)}};const ka=ya(wa);const Aa=function(t,e){return ka(ga(t,e,ua),t+"")};const xa=function(t,e,i){if(!F(i))return!1;var n=typeof e;return!!("number"==n?vi(i)&&ei(e,i.length):"string"==n&&e in i)&&Ot(i[e],t)};const Ca=function(t){return Aa((function(e,i){var n=-1,s=i.length,o=s>1?i[s-1]:void 0,r=s>2?i[2]:void 0;for(o=t.length>3&&"function"==typeof o?(s--,o):void 0,r&&xa(i[0],i[1],r)&&(o=s<3?void 0:o,s=1),e=Object(e);++ne===t));return Array.isArray(e)}set(t,e){if(F(t))for(const[e,i]of Object.entries(t))this._styleProcessor.toNormalizedForm(e,i,this._styles);else this._styleProcessor.toNormalizedForm(t,e,this._styles)}remove(t){const e=Oa(t);na(this._styles,e),delete this._styles[t],this._cleanEmptyObjectsOnPath(e)}getNormalized(t){return this._styleProcessor.getNormalized(t,this._styles)}toString(){return this.isEmpty?"":this._getStylesEntries().map((t=>t.join(":"))).sort().join(";")+";"}getAsString(t){if(this.isEmpty)return;if(this._styles[t]&&!F(this._styles[t]))return this._styles[t];const e=this._styleProcessor.getReducedForm(t,this._styles).find((([e])=>e===t));return Array.isArray(e)?e[1]:void 0}getStyleNames(t=!1){if(this.isEmpty)return[];if(t)return this._styleProcessor.getStyleNames(this._styles);return this._getStylesEntries().map((([t])=>t))}clear(){this._styles={}}_getStylesEntries(){const t=[],e=Object.keys(this._styles);for(const i of e)t.push(...this._styleProcessor.getReducedForm(i,this._styles));return t}_cleanEmptyObjectsOnPath(t){const e=t.split(".");if(!(e.length>1))return;const i=e.splice(0,e.length-1).join("."),n=sa(this._styles,i);if(!n)return;!Array.from(Object.keys(n)).length&&this.remove(i)}}class Ra{constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(t,e,i){if(F(e))Ia(i,Oa(t),e);else if(this._normalizers.has(t)){const n=this._normalizers.get(t),{path:s,value:o}=n(e);Ia(i,s,o)}else Ia(i,t,e)}getNormalized(t,e){if(!t)return Pa({},e);if(void 0!==e[t])return e[t];if(this._extractors.has(t)){const i=this._extractors.get(t);if("string"==typeof i)return sa(e,i);const n=i(t,e);if(n)return n}return sa(e,Oa(t))}getReducedForm(t,e){const i=this.getNormalized(t,e);if(void 0===i)return[];if(this._reducers.has(t)){return this._reducers.get(t)(i)}return[[t,i]]}getStyleNames(t){const e=Array.from(this._consumables.keys()).filter((e=>{const i=this.getNormalized(e,t);return i&&"object"==typeof i?Object.keys(i).length:i})),i=new Set([...e,...Object.keys(t)]);return Array.from(i.values())}getRelatedStyles(t){return this._consumables.get(t)||[]}setNormalizer(t,e){this._normalizers.set(t,e)}setExtractor(t,e){this._extractors.set(t,e)}setReducer(t,e){this._reducers.set(t,e)}setStyleRelation(t,e){this._mapStyleNames(t,e);for(const i of e)this._mapStyleNames(i,[t])}_mapStyleNames(t,e){this._consumables.has(t)||this._consumables.set(t,[]),this._consumables.get(t).push(...e)}}function Oa(t){return t.replace("-",".")}function Ia(t,e,i){let n=i;F(i)&&(n=Pa({},sa(t,e),i)),Ea(t,e,n)}class Va extends xr{constructor(t,e,i,n){if(super(t),this.name=e,this._attrs=function(t){const e=mo(t);for(const[t,i]of e)null===i?e.delete(t):"string"!=typeof i&&e.set(t,String(i));return e}(i),this._children=[],n&&this._insertChild(0,n),this._classes=new Set,this._attrs.has("class")){const t=this._attrs.get("class");Ma(this._classes,t),this._attrs.delete("class")}this._styles=new Sa(this.document.stylesProcessor),this._attrs.has("style")&&(this._styles.setTo(this._attrs.get("style")),this._attrs.delete("style")),this._customProperties=new Map,this._unsafeAttributesToRender=[]}get childCount(){return this._children.length}get isEmpty(){return 0===this._children.length}getChild(t){return this._children[t]}getChildIndex(t){return this._children.indexOf(t)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes.size>0&&(yield"class"),this._styles.isEmpty||(yield"style"),yield*this._attrs.keys()}*getAttributes(){yield*this._attrs.entries(),this._classes.size>0&&(yield["class",this.getAttribute("class")]),this._styles.isEmpty||(yield["style",this.getAttribute("style")])}getAttribute(t){if("class"==t)return this._classes.size>0?[...this._classes].join(" "):void 0;if("style"==t){const t=this._styles.toString();return""==t?void 0:t}return this._attrs.get(t)}hasAttribute(t){return"class"==t?this._classes.size>0:"style"==t?!this._styles.isEmpty:this._attrs.has(t)}isSimilar(t){if(!(t instanceof Va))return!1;if(this===t)return!0;if(this.name!=t.name)return!1;if(this._attrs.size!==t._attrs.size||this._classes.size!==t._classes.size||this._styles.size!==t._styles.size)return!1;for(const[e,i]of this._attrs)if(!t._attrs.has(e)||t._attrs.get(e)!==i)return!1;for(const e of this._classes)if(!t._classes.has(e))return!1;for(const e of this._styles.getStyleNames())if(!t._styles.has(e)||t._styles.getAsString(e)!==this._styles.getAsString(e))return!1;return!0}hasClass(...t){for(const e of t)if(!this._classes.has(e))return!1;return!0}getClassNames(){return this._classes.keys()}getStyle(t){return this._styles.getAsString(t)}getNormalizedStyle(t){return this._styles.getNormalized(t)}getStyleNames(t){return this._styles.getStyleNames(t)}hasStyle(...t){for(const e of t)if(!this._styles.has(e))return!1;return!0}findAncestor(...t){const e=new Tr(...t);let i=this.parent;for(;i&&!i.is("documentFragment");){if(e.match(i))return i;i=i.parent}return null}getCustomProperty(t){return this._customProperties.get(t)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const t=Array.from(this._classes).sort().join(","),e=this._styles.toString(),i=Array.from(this._attrs).map((t=>`${t[0]}="${t[1]}"`)).sort().join(" ");return this.name+(""==t?"":` class="${t}"`)+(e?` style="${e}"`:"")+(""==i?"":` ${i}`)}shouldRenderUnsafeAttribute(t){return this._unsafeAttributesToRender.includes(t)}_clone(t=!1){const e=[];if(t)for(const i of this.getChildren())e.push(i._clone(t));const i=new this.constructor(this.document,this.name,this._attrs,e);return i._classes=new Set(this._classes),i._styles.set(this._styles.getNormalized()),i._customProperties=new Map(this._customProperties),i.getFillerOffset=this.getFillerOffset,i._unsafeAttributesToRender=this._unsafeAttributesToRender,i}_appendChild(t){return this._insertChild(this.childCount,t)}_insertChild(t,e){this._fireChange("children",this);let i=0;const n=function(t,e){if("string"==typeof e)return[new Cr(t,e)];tt(e)||(e=[e]);return Array.from(e).map((e=>"string"==typeof e?new Cr(t,e):e instanceof Pr?new Cr(t,e.data):e))}(this.document,e);for(const e of n)null!==e.parent&&e._remove(),e.parent=this,e.document=this.document,this._children.splice(t,0,e),t++,i++;return i}_removeChildren(t,e=1){this._fireChange("children",this);for(let i=t;is?(t.nodesToHandle=n-s,t.offset=s):t.nodesToHandle=0);if("remove"==i.type&&t.offset
").replace(/\r?\n/g,"
").replace(/\t/g," ").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("
")||o.includes("
"))&&(o=`
${o}
`),t=o),s=this.editor.data.htmlProcessor.toView(t)}var o;const r=new m(this,"inputTransformation");this.fire(r,{content:s,dataTransfer:n,targetRanges:e.targetRanges,method:e.method}),r.stop.called&&t.stop(),i.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((t,i)=>{if(i.content.isEmpty)return;const n=this.editor.data.toModel(i.content,"$clipboardHolder");0!=n.childCount&&(t.stop(),e.change((()=>{this.fire("contentInsertion",{content:n,method:i.method,dataTransfer:i.dataTransfer,targetRanges:i.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((t,i)=>{i.resultRange=e.insertContent(i.content)}),{priority:"low"})}_setupCopyCut(){const t=this.editor,e=t.model.document,i=t.editing.view.document,n=(n,s)=>{const o=s.dataTransfer;s.preventDefault();const r=t.data.toView(t.model.getSelectedContent(e.selection));i.fire("clipboardOutput",{dataTransfer:o,content:r,method:n.name})};this.listenTo(i,"copy",n,{priority:"low"}),this.listenTo(i,"cut",((e,i)=>{t.isReadOnly?i.preventDefault():n(e,i)}),{priority:"low"}),this.listenTo(i,"clipboardOutput",((i,n)=>{n.content.isEmpty||(n.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(n.content)),n.dataTransfer.setData("text/plain",Ig(n.content))),"cut"==n.method&&t.model.deleteContent(e.selection)}),{priority:"low"})}}class Mg extends(R()){constructor(){super(),this._stack=[]}add(t,e){const i=this._stack,n=i[0];this._insertDescriptor(t);const s=i[0];n===s||Ng(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:e})}remove(t,e){const i=this._stack,n=i[0];this._removeDescriptor(t);const s=i[0];n===s||Ng(n,s)||this.fire("change:top",{oldDescriptor:n,newDescriptor:s,writer:e})}_insertDescriptor(t){const e=this._stack,i=e.findIndex((e=>e.id===t.id));if(Ng(t,e[i]))return;i>-1&&e.splice(i,1);let n=0;for(;e[n]&&Bg(e[n],t);)n++;e.splice(n,0,t)}_removeDescriptor(t){const e=this._stack,i=e.findIndex((e=>e.id===t));i>-1&&e.splice(i,1)}}function Ng(t,e){return t&&e&&t.priority==e.priority&&Dg(t.classes)==Dg(e.classes)}function Bg(t,e){return t.priority>e.priority||!(t.priority