// WoltLabButton.js
$.Redactor.prototype.WoltLabButton=function(){"use strict";return{init:function(){var t,s,o,e;for(o=0,e=this.opts.woltlab.customButtons.length;e>o;o++)s=this.opts.woltlab.customButtons[o],t=this.button.add(s,""),this.button.addCallback(t,this.WoltLabButton._handleCustomButton);var n;for(o=0,e=this.opts.buttons.length;e>o;o++)if(s=this.opts.buttons[o],"wcfSeparator"!==s){if(!this.opts.woltlab.buttons.hasOwnProperty(s))throw new Error("Missing button definition for '"+s+"'.");switch(n=this.opts.woltlab.buttons[s],"underline"===s&&(this.opts.activeButtonsStates.u="underline"),s){case"subscript":case"superscript":t=this.button.addAfter(this.opts.buttons[o-1],s,""),this.button.setEvent(t,s,{func:"inline.format"}),this.opts.activeButtonsStates["subscript"===s?"sub":"sup"]=s;break;case"redo":case"undo":t=this.button.addAfter(this.opts.buttons[o-1],s,""),this.button.addCallback(t,this.buffer[s]);break;default:t=this.button.get(s)}if(this.button.setIcon(t,'<span class="icon icon16 '+n.icon+'"></span>'),!t[0])throw new Error("Missing button element for '"+s+"'.");elAttr(t[0],"title",n.title),t[0].classList.add("jsTooltip")}for(var i,r={},a=[],l=this.core.toolbar()[0];l.childElementCount;)i=l.removeChild(l.children[0]),s=elAttr(i.children[0],"rel"),r[s]=i,a.push(s);var h=!1;for(o=0,e=this.opts.buttons.length;e>o;o++)s=this.opts.buttons[o],"wcfSeparator"!==s?(i=r[s],l.appendChild(i),a.splice(a.indexOf(s),1),h&&(i.classList.add("redactor-toolbar-separator"),h=!1)):h=!0;for(o=0,e=l.childElementCount;e>o;o++)i=l.children[o],t=i.children[0],elData(i,"show-on-mobile",-1!==this.opts.woltlab.buttonMobile.indexOf(t.rel));a.forEach(function(t){l.appendChild(r[t])}),WCF.DOMNodeInsertedHandler.execute()},_handleCustomButton:function(t){var s={cancel:!1};if(WCF.System.Event.fireEvent("com.woltlab.wcf.redactor2","bbcode_"+t+"_"+this.$element[0].id,s),s.cancel!==!0){this.buffer.set();var o="["+t+"]"+this.selection.html()+(this.selection.is()?"":this.marker.html())+"[/"+t+"]";this.insert.html(o),this.selection.restore()}}}};
// WoltLabCaret.js
-$.Redactor.prototype.WoltLabCaret=function(){"use strict";return{init:function(){var t=this.caret.after;this.caret.after=function(e){e=this.caret.prepare(e),this.utils.isBlockTag(e.tagName)&&this.WoltLabCaret._addParagraphAfterBlock(e),t.call(this,e)}.bind(this),this.$editor[0].addEventListener("mouseup",this.WoltLabCaret._handleEditorClick.bind(this)),this.WoltLabCaret._initInternalRange()},endOfEditor:function(){var t=this.core.editor()[0];document.activeElement!==t&&t.focus();var e=t.lastElementChild;"P"===e.nodeName?this.caret.end(e):this.caret.after(e)},_initInternalRange:function(){var t=this.core.editor()[0],e=null,i=window.getSelection(),n=function(){e=i.rangeCount?i.getRangeAt(0).cloneRange():null},r=function(){if(null!==e){if(document.activeElement===t){var n=i.getRangeAt(0);if(0!==n.startOffset)return;for(var r=n.startContainer;r;){if(r.parentNode===t){if(r.previousSibling)return;break}if(r.previousSibling)return;r=r.parentNode}if(!r)return}t.focus(),i.removeAllRanges(),i.addRange(e),e=null}};this.$editor[0].addEventListener("keyup",n),this.$editor[0].addEventListener("mouseup",function(){i.rangeCount&&n()});var a=this.selection.save;this.selection.save=function(){e=null,a.call(this)}.bind(this);var o=this.selection.restore;this.selection.restore=function(){e&&(r(),i.rangeCount&&this.utils.isRedactorParent(i.getRangeAt(0).commonAncestorContainer))||o.call(this)}.bind(this);var s=this.buffer.set;this.buffer.set=function(e){document.activeElement!==t&&r(),s.call(this,e),n()}.bind(this);var l=this.insert.html;this.insert.html=function(t,e){l.call(this,t,e),n()}.bind(this)},_handleEditorClick:function(t){if(t.target===this.$editor[0]&&this.selection.get().isCollapsed){var e=this.selection.block();if(e!==!1&&("P"!==e.nodeName||(e=e.parentNode,e!==this.$editor[0]&&this.utils.isBlockTag(e.nodeName)))){if("TD"===e.nodeName)for(;"TABLE"!==e.nodeName;)e=e.parentNode;this.buffer.set();var i=t.clientY<e.getBoundingClientRect().top,n=elCreate("p");n.textContent="",e.parentNode.insertBefore(n,i?e:e.nextSibling),this.caret.end(n)}}},_addParagraphAfterBlock:function(t){var e=t.nextElementSibling;(!e||"P"!==e.nodeName&&!this.utils.isBlockTag(e.nodeName))&&(e=elCreate("p"),e.textContent="",t.parentNode.insertBefore(e,t.nextSibling))}}};
+$.Redactor.prototype.WoltLabCaret=function(){"use strict";return{init:function(){var t=this.caret.after;this.caret.after=function(e){e=this.caret.prepare(e),this.utils.isBlockTag(e.tagName)&&this.WoltLabCaret._addParagraphAfterBlock(e),t.call(this,e)}.bind(this),this.$editor[0].addEventListener("mouseup",this.WoltLabCaret._handleEditorClick.bind(this)),this.WoltLabCaret._initInternalRange()},endOfEditor:function(){var t=this.core.editor()[0];document.activeElement!==t&&t.focus();var e=t.lastElementChild;"P"===e.nodeName?this.caret.end(e):this.caret.after(e)},_initInternalRange:function(){var t=this.core.editor()[0],e=null,i=window.getSelection(),n=function(){e=i.rangeCount?i.getRangeAt(0).cloneRange():null},r=function(){if(null!==e){if(document.activeElement===t){var n=i.getRangeAt(0);if(0!==n.startOffset)return;for(var r=n.startContainer;r;){if(r.parentNode===t){if(r.previousSibling)return;break}if(r.previousSibling)return;r=r.parentNode}if(!r)return}t.focus(),i.removeAllRanges(),i.addRange(e),e=null}};this.$editor[0].addEventListener("keyup",n),this.$editor[0].addEventListener("mouseup",function(){i.rangeCount&&n()});var a=this.selection.save;this.selection.save=function(){e=null,a.call(this)}.bind(this);var o=this.selection.restore;this.selection.restore=function(){e&&(r(),i.rangeCount&&this.utils.isRedactorParent(i.getRangeAt(0).commonAncestorContainer))||o.call(this)}.bind(this);var s=this.buffer.set;this.buffer.set=function(e){document.activeElement!==t&&r(),s.call(this,e),n()}.bind(this);var l=this.insert.html;this.insert.html=function(t,e){l.call(this,t,e),n()}.bind(this)},_handleEditorClick:function(t){if(t.target===this.$editor[0]&&this.selection.get().isCollapsed){var e=this.selection.block();if(e!==!1&&("P"!==e.nodeName||(e=e.parentNode,e!==this.$editor[0]&&this.utils.isBlockTag(e.nodeName)))){if("TD"===e.nodeName)for(;"TABLE"!==e.nodeName;)e=e.parentNode;if(!e.nodeName.match(/^H\d$/)){this.buffer.set();var i=t.clientY<e.getBoundingClientRect().top,n=elCreate("p");n.textContent="",e.parentNode.insertBefore(n,i?e:e.nextSibling),this.caret.end(n)}}}},_addParagraphAfterBlock:function(t){var e=t.nextElementSibling;(!e||"P"!==e.nodeName&&!this.utils.isBlockTag(e.nodeName))&&(e=elCreate("p"),e.textContent="",t.parentNode.insertBefore(e,t.nextSibling))}}};
// WoltLabClean.js
$.Redactor.prototype.WoltLabClean=function(){"use strict";return{init:function(){this.opts.pasteInlineTags=this.opts.pasteInlineTags.filter(function(n){return"span"!==n});var n=this.clean.onSet;this.clean.onSet=function(t){return n.call(this,t.replace(/\u200B/g,""))}.bind(this);var t=this.clean.onSync;this.clean.onSync=function(n){var e=elCreate("div"),i={};return-1!==n.indexOf("<pre")&&(e.innerHTML=n,elBySelAll("pre",e,function(n){var t=WCF.getUUID();i[t]=n.textContent,n.textContent=t}),n=e.innerHTML),n=t.call(this,n),e.innerHTML=n,elBySelAll("span",e,function(n){n.outerHTML=n.innerHTML}),elBySelAll("pre",e,function(n){i.hasOwnProperty(n.textContent)&&(n.textContent=i[n.textContent])}),n=e.innerHTML}.bind(this);var e=this.clean.savePreFormatting;this.clean.savePreFormatting=function(n){var t=this.clean.encodeEntities;return this.clean.encodeEntities=function(n){return WCF.String.escapeHTML(n)},n=e.call(this,n),this.clean.encodeEntities=t,n}.bind(this);var i=this.clean.stripTags;this.clean.stripTags=function(n,t){return Array.isArray(t)&&t.push("span"),i.call(this,n,t)}.bind(this)}}};
// WoltLabCode.js