// WoltLabPage.js
$.Redactor.prototype.WoltLabPage=function(){"use strict";return{init:function(){var t=this.button.add("woltlabPage","");require(["WoltLabSuite/Core/Ui/Redactor/Page"],function(e){new e(this,t[0])}.bind(this))}}};
// WoltLabPaste.js
-$.Redactor.prototype.WoltLabPaste=function(){"use strict";return{init:function(){var e=null,t=!1,i=document.documentMode&&"object"==typeof window.clipboardData,r=this.paste.init;this.paste.init=function(a){var n="pre"===this.opts.type||this.utils.isCurrentOrParent("pre");if(t=!n&&this.utils.isCurrentOrParent("kbd"),n||t){e=i?window.clipboardData.getData("Text"):a.originalEvent.clipboardData.getData("text/plain");var s=this.clean.encodeEntities;this.clean.encodeEntities=function(e){return this.clean.encodeEntities=s,WCF.String.escapeHTML(e)}.bind(this)}r.call(this,a)}.bind(this);var a=this.paste.getPasteBoxCode;this.paste.getPasteBoxCode=function(r){var n=a.call(this,r);return t?e:!r||n&&!i?n:e}.bind(this),this.core.editor().off("paste.redactor").on("paste.redactor",this.paste.init.bind(this)),this.paste.detectClipboardUpload=function(e){e=e.originalEvent||e;var t;if(i){if(!window.clipboardData.files.length)return!1;t=window.clipboardData.files.item(0)}else{if(this.detect.isFirefox())return!1;var r=e.clipboardData,a=r.types;if(Array.isArray(a)&&-1!==a.indexOf("public.tiff"))return e.preventDefault(),!1;if(!r.items||!r.items.length)return;var n=!1;if(t=r.items[0].getAsFile(),null===t&&(this.detect.isWebkit()&&r.items.length>1&&(t=r.items[1].getAsFile(),n=!0),null===t))return!1}var s=new FileReader;return s.readAsDataURL(t),s.onload=this.paste.insertFromClipboard.bind(this),n===!1}.bind(this),this.paste.insertFromClipboard=function(e){window.FormData&&(this.buffer.set(),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this.$element[0].id,{blob:this.utils.dataURItoBlob(e.target.result)}),this.rtePaste=!1)}.bind(this);var n="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",s=this.paste.insert;this.paste.insert=function(e,t){if(t.pre)return s.call(this,e,t);if(this.utils.isCurrentOrParent("kbd")){s.call(this,e,t);var i=this.selection.current();i.nodeType===Node.TEXT_NODE&&(i=i.parentNode);for(var r=i.closest("kbd"),a=elByTag("p",r);a.length;)a[0].outerHTML=a[0].innerHTML;var l=r.innerHTML.split(/<br\s*\/?>/);if(l.length>1){for(var o=this.selection.block(),d=1,c=l.length;c>d;d++){var h=elCreate(o.nodeName);h.innerHTML="<kbd>"+l[d]+(d===c-1?this.marker.html():"")+"</kbd>",o.parentNode.insertBefore(h,o.nextSibling),o=h}r.innerHTML=l[0],this.selection.restore()}}else{var p=elCreate("div");p.innerHTML=e;var u=[];t.pre||t.text||elBySelAll("img",p,function(e){var t=e.src;if(0===t.indexOf("data:image")&&t!==n){e.src=n;var i=WCF.getUUID();elData(e,"uuid",i),u.push({src:t,uuid:i}),elHide(e)}}.bind(this)),elBySelAll(".redactor-selection-marker",p,elRemove),p.appendChild(elCreate("woltlab-selection-marker")),s.call(this,p.innerHTML,t);var f=elBySel("woltlab-selection-marker",this.$editor[0]);if(f){var b=document.createRange();b.setStartBefore(f),b.setEndBefore(f);var A=window.getSelection();A.removeAllRanges(),A.addRange(b),elRemove(f)}u.length&&window.setTimeout(function(){for(var e,t,i=0,r=u.length;r>i;i++)e=u[i],t=elBySel('img[data-uuid="'+e.uuid+'"]',this.$editor[0]),t&&WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this.$element[0].id,{blob:this.utils.dataURItoBlob(e.src),replace:t})}.bind(this),50),this.rtePaste=!1}}.bind(this),this.paste.clipboardUpload=function(){}}}};
+$.Redactor.prototype.WoltLabPaste=function(){"use strict";return{init:function(){var e=null,t=!1,i=document.documentMode&&"object"==typeof window.clipboardData,r=this.paste.init;this.paste.init=function(a){var n="pre"===this.opts.type||this.utils.isCurrentOrParent("pre");if(t=!n&&this.utils.isCurrentOrParent("kbd"),n||t){e=i?window.clipboardData.getData("Text"):a.originalEvent.clipboardData.getData("text/plain");var s=this.clean.encodeEntities;this.clean.encodeEntities=function(e){return this.clean.encodeEntities=s,WCF.String.escapeHTML(e)}.bind(this)}r.call(this,a)}.bind(this);var a=this.paste.getPasteBoxCode;this.paste.getPasteBoxCode=function(r){var n=a.call(this,r);return t?e:!r||n&&!i?n:e}.bind(this),this.core.editor().off("paste.redactor").on("paste.redactor",this.paste.init.bind(this)),this.paste.detectClipboardUpload=function(e){e=e.originalEvent||e;var t;if(i){if(!window.clipboardData.files.length)return!1;t=window.clipboardData.files.item(0)}else{if(this.detect.isFirefox())return!1;var r=e.clipboardData,a=r.types;if(Array.isArray(a)&&-1!==a.indexOf("public.tiff"))return e.preventDefault(),!1;if(!r.items||!r.items.length)return;var n=!1;if(t=r.items[0].getAsFile(),null===t&&(this.detect.isWebkit()&&r.items.length>1&&(t=r.items[1].getAsFile(),n=!0,e.preventDefault()),null===t))return!1}var s=new FileReader;return s.readAsDataURL(t),s.onload=this.paste.insertFromClipboard.bind(this),n===!1}.bind(this),this.paste.insertFromClipboard=function(e){window.FormData&&(this.buffer.set(),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this.$element[0].id,{blob:this.utils.dataURItoBlob(e.target.result)}),this.rtePaste=!1)}.bind(this);var n="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",s=this.paste.insert;this.paste.insert=function(e,t){if(t.pre)return s.call(this,e,t);if(this.utils.isCurrentOrParent("kbd")){s.call(this,e,t);var i=this.selection.current();i.nodeType===Node.TEXT_NODE&&(i=i.parentNode);for(var r=i.closest("kbd"),a=elByTag("p",r);a.length;)a[0].outerHTML=a[0].innerHTML;var l=r.innerHTML.split(/<br\s*\/?>/);if(l.length>1){for(var o=this.selection.block(),d=1,c=l.length;c>d;d++){var h=elCreate(o.nodeName);h.innerHTML="<kbd>"+l[d]+(d===c-1?this.marker.html():"")+"</kbd>",o.parentNode.insertBefore(h,o.nextSibling),o=h}r.innerHTML=l[0],this.selection.restore()}}else{var p=elCreate("div");p.innerHTML=e;var u=[];t.pre||t.text||elBySelAll("img",p,function(e){var t=e.src;if(0===t.indexOf("data:image")&&t!==n){e.src=n;var i=WCF.getUUID();elData(e,"uuid",i),u.push({src:t,uuid:i}),elHide(e)}}.bind(this)),elBySelAll(".redactor-selection-marker",p,elRemove),p.appendChild(elCreate("woltlab-selection-marker")),s.call(this,p.innerHTML,t);var f=elBySel("woltlab-selection-marker",this.$editor[0]);if(f){var b=document.createRange();b.setStartBefore(f),b.setEndBefore(f);var A=window.getSelection();A.removeAllRanges(),A.addRange(b),elRemove(f)}u.length&&window.setTimeout(function(){for(var e,t,i=0,r=u.length;r>i;i++)e=u[i],t=elBySel('img[data-uuid="'+e.uuid+'"]',this.$editor[0]),t&&WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","pasteFromClipboard_"+this.$element[0].id,{blob:this.utils.dataURItoBlob(e.src),replace:t})}.bind(this),50),this.rtePaste=!1}}.bind(this),this.paste.clipboardUpload=function(){}}}};
// WoltLabQuote.js
$.Redactor.prototype.WoltLabQuote=function(){"use strict";return{init:function(){var t=this.button.add("woltlabQuote","");this.WoltLabBlock.register("woltlab-quote",!0),this.opts.replaceTags.blockquote="woltlab-quote",this.opts.activeButtonsStates["woltlab-quote"]="woltlabQuote",require(["WoltLabSuite/Core/Ui/Redactor/Quote"],function(o){new o(this,t)}.bind(this))}}};
// WoltLabReply.js
// WoltLabSmiley.js
$.Redactor.prototype.WoltLabSmiley=function(){"use strict";var t=0;return{init:function(){require(["EventHandler"],function(t){t.add("com.woltlab.wcf.redactor2","insertSmiley_"+this.$element[0].id,this.WoltLabSmiley._insert.bind(this))}.bind(this))},_insert:function(i){if(!this.WoltLabSource.isActive()){this.buffer.set();var e="wscSmiley_"+this.uuid+"_"+t++,r=i.img.cloneNode();r.id=e,this.insert.html(r.outerHTML),r=elById(e),r.removeAttribute("id"),this.caret.after(r),r.outerHTML=r.outerHTML}}}};
// WoltLabSource.js
-$.Redactor.prototype.WoltLabSource=function(){"use strict";return{init:function(){function e(e){elBySelAll(".icon, .fa",e,function(e){var t=e.className.split(" ");t=t.filter(function(e){return"fa"===e||"icon"===e?!1:e.match(/^icon\d{2}$/)?!1:e.match(/^fa-[a-z\-]+$/)?!1:!0}),e.className=t.join(" "),""===e.className.trim()&&""===e.innerHTML&&elRemove(e)})}var t=this.$element[0].id,n=function(e){elBySelAll("woltlab-quote",e,function(e){if(2===e.childElementCount&&"P"===e.children[0].nodeName&&"P"===e.children[1].nodeName){var t=e.children[0];if(""===t.innerHTML.trim()){var n=e.children[1];"<br>"===n.innerHTML.trim()&&e.removeChild(t)}}})},i=function(e){elBySelAll("pre, woltlab-quote, woltlab-spoiler",e,function(e){e.removeAttribute("data-title")}),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","source_"+i+"_"+t,{div:e})};this.source.setCaretOnShow=function(){},this.source.setCaretOnHide=function(e){return e};var r=this.source.hide;this.source.hide=function(){var t=$("<div />").html(this.source.$textarea.val());e(t[0]),this.source.$textarea.val(t[0].innerHTML),r.call(this),setTimeout(function(){this.focus.end(),n(this.core.editor()[0])}.bind(this),100),this.placeholder.enable()}.bind(this);var o=this.source.$textarea[0];this.$element[0].parentNode.insertBefore(o,this.$element[0]);var l=this.source.show;this.source.show=function(){var e=this.$editor[0].offsetHeight;l.call(this),o.style.setProperty("height",Math.ceil(e)+"px",""),o.style.setProperty("display","block","");var t=elCreate("div");t.innerHTML=o.value,n(t),i(t),o.value=this.WoltLabSource.format(t.innerHTML),o.selectionStart=o.selectionEnd=o.value.length}.bind(this),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","validate_"+t,function(e){o.clientHeight&&(e.api.throwError(this.$element[0],WCF.Language.get("wcf.editor.source.error.active")),e.valid=!1)}.bind(this))},isActive:function(){return"none"===this.$editor[0].style.getPropertyValue("display")},format:function(e){var t=["ul","ol","li"];this.block.tags.forEach(function(e){t.push(e)}),t=t.join("|").toLowerCase();var n=["p","li"],i="[^'\">]*(?:(?:\"[^\"]*\"|'[^']*')[^'\">]*)*",r=[];e=e.replace(new RegExp("<pre"+i+">[sS]*?</pre>","g"),function(e){return r.push(e),"@@@WCF_PRE_BACKUP_"+(r.length-1)+"@@@"}),e=e.replace(new RegExp("\\s*</("+t+")>\\s*","g"),function(e,t){return(-1===n.indexOf(t)?"\n":"")+"</"+t+">"}),e=e.replace(new RegExp("\\s*<("+t+")("+i+")>\\s*","g"),function(e,t,i){return"\n<"+t+i+">"+(-1===n.indexOf(t)?"\n":"")}),e=e.replace(/<woltlab-quote([^>]*)>\n\t*\n(\t*)<p/,"<woltlab-quote$1>\n$2<p"),e=e.replace(new RegExp("<(ol|ul)("+i+")>\\s*","g"),"<$1$2>\n");var o,l,a,s=e.split(/\n/),c=0,u=new RegExp("^<("+t+")"),h=new RegExp("^</(?:"+t+")>$"),f=!1;for(o=0,l=s.length;l>o;o++){if(a=s[o],f=!1,a.match(u)?-1===n.indexOf(RegExp.$1)&&(f=!0):a.match(h)&&c--,c>0){var d=c;for(s[o]="";d--;)s[o]+=" ";s[o]+=a}f&&c++}for(e=s.join("\n"),o=0,l=r.length;l>o;o++)e=e.replace("@@@WCF_PRE_BACKUP_"+o+"@@@",r[o]);return e.trim()}}};
+$.Redactor.prototype.WoltLabSource=function(){"use strict";return{init:function(){function e(e){elBySelAll(".icon, .fa",e,function(e){var t=e.className.split(" ");t=t.filter(function(e){return"fa"===e||"icon"===e?!1:e.match(/^icon\d{2}$/)?!1:e.match(/^fa-[a-z\-]+$/)?!1:!0}),e.className=t.join(" "),""===e.className.trim()&&""===e.innerHTML&&elRemove(e)})}var t=this.$element[0].id,n=function(e){elBySelAll("woltlab-quote",e,function(e){if(2===e.childElementCount&&"P"===e.children[0].nodeName&&"P"===e.children[1].nodeName){var t=e.children[0];if(""===t.innerHTML.trim()){var n=e.children[1];"<br>"===n.innerHTML.trim()&&e.removeChild(t)}}})},i=function(e){elBySelAll("pre, woltlab-quote, woltlab-spoiler",e,function(e){e.removeAttribute("data-title")}),WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","source_stripIntermediateCode_"+t,{div:e})};this.source.setCaretOnShow=function(){},this.source.setCaretOnHide=function(e){return e};var r=this.source.hide;this.source.hide=function(){var t=$("<div />").html(this.source.$textarea.val());e(t[0]),this.source.$textarea.val(t[0].innerHTML),r.call(this),setTimeout(function(){this.focus.end(),n(this.core.editor()[0])}.bind(this),100),this.placeholder.enable()}.bind(this);var o=this.source.$textarea[0];this.$element[0].parentNode.insertBefore(o,this.$element[0]);var l=this.source.show;this.source.show=function(){var e=this.$editor[0].offsetHeight;l.call(this),o.style.setProperty("height",Math.ceil(e)+"px",""),o.style.setProperty("display","block","");var t=elCreate("div");t.innerHTML=o.value,n(t),i(t),o.value=this.WoltLabSource.format(t.innerHTML),o.selectionStart=o.selectionEnd=o.value.length}.bind(this),WCF.System.Event.addListener("com.woltlab.wcf.redactor2","validate_"+t,function(e){o.clientHeight&&(e.api.throwError(this.$element[0],WCF.Language.get("wcf.editor.source.error.active")),e.valid=!1)}.bind(this))},isActive:function(){return"none"===this.$editor[0].style.getPropertyValue("display")},format:function(e){var t=["ul","ol","li"];this.block.tags.forEach(function(e){t.push(e)}),t=t.join("|").toLowerCase();var n=["p","li"],i="[^'\">]*(?:(?:\"[^\"]*\"|'[^']*')[^'\">]*)*",r=[];e=e.replace(new RegExp("<pre"+i+">[sS]*?</pre>","g"),function(e){return r.push(e),"@@@WCF_PRE_BACKUP_"+(r.length-1)+"@@@"}),e=e.replace(new RegExp("\\s*</("+t+")>\\s*","g"),function(e,t){return(-1===n.indexOf(t)?"\n":"")+"</"+t+">"}),e=e.replace(new RegExp("\\s*<("+t+")("+i+")>\\s*","g"),function(e,t,i){return"\n<"+t+i+">"+(-1===n.indexOf(t)?"\n":"")}),e=e.replace(/<woltlab-quote([^>]*)>\n\t*\n(\t*)<p/,"<woltlab-quote$1>\n$2<p"),e=e.replace(new RegExp("<(ol|ul)("+i+")>\\s*","g"),"<$1$2>\n");var o,l,a,s=e.split(/\n/),c=0,u=new RegExp("^<("+t+")"),h=new RegExp("^</(?:"+t+")>$"),f=!1;for(o=0,l=s.length;l>o;o++){if(a=s[o],f=!1,a.match(u)?-1===n.indexOf(RegExp.$1)&&(f=!0):a.match(h)&&c--,c>0){var d=c;for(s[o]="";d--;)s[o]+=" ";s[o]+=a}f&&c++}for(e=s.join("\n"),o=0,l=r.length;l>o;o++)e=e.replace("@@@WCF_PRE_BACKUP_"+o+"@@@",r[o]);return e.trim()}}};
// WoltLabSpoiler.js
$.Redactor.prototype.WoltLabSpoiler=function(){"use strict";return{init:function(){this.WoltLabBlock.register("woltlab-spoiler",!0),this.opts.activeButtonsStates["woltlab-spoiler"]="woltlabSpoiler",require(["WoltLabSuite/Core/Ui/Redactor/Spoiler"],function(t){new t(this)}.bind(this))}}};
// WoltLabTable.js