!function(){"use strict";var n=function(e){var t=e,r=function(){return t};return{get:r,set:function(n){t=n},clone:function(){return n(r())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(n){return{isEnabled:function(){return n.get()}}},r=function(n,e){return n.fire("VisualChars",{state:e})},o={"\xa0":"nbsp","\xad":"shy"},u=function(n,e){var t,r="";for(t in n)r+=t;return new RegExp("["+r+"]",e?"g":"")},i=function(n){var e,t="";for(e in n)t&&(t+=","),t+="span.mce-"+n[e];return t},c={charMap:o,regExp:u(o),regExpGlobal:u(o,!0),selector:i(o),charMapToRegExp:u,charMapToSelector:i},a=function(n){return function(){return n}},f={noop:function(){},noarg:function(n){return function(){return n()}},compose:function(n,e){return function(){return n(e.apply(null,arguments))}},constant:a,identity:function(n){return n},tripleEquals:function(n,e){return n===e},curry:function(n){for(var e=new Array(arguments.length-1),t=1;t1)throw console.error("HTML does not have a single root node",n),"HTML must have a single root node";return x(t.childNodes[0])},fromTag:function(n,e){var t=(e||document).createElement(n);return x(t)},fromText:function(n,e){var t=(e||document).createTextNode(n);return x(t)},fromDom:x,fromPoint:function(n,e,t){return p.from(n.dom().elementFromPoint(e,t)).map(x)}},b=8,k=9,N=3,C=function(n){return n.dom().nodeName.toLowerCase()},M=function(n){return n.dom().nodeType},D=function(n){return function(e){return M(e)===n}},O=D(1),A=D(N),S=D(k),B={name:C,type:M,value:function(n){return n.dom().nodeValue},isElement:O,isText:A,isDocument:S,isComment:function(n){return M(n)===b||"#comment"===C(n)}},P=function(n){return''+n+""},V=function(n,e){var t=[],r=n.dom(),o=T(r.childNodes,E.fromDom);return w(o,function(n){e(n)&&(t=t.concat([n])),t=t.concat(V(n,e))}),t},q={isMatch:function(n){return B.isText(n)&&B.value(n)!==undefined&&c.regExp.test(B.value(n))},filterDescendants:V,findParentElm:function(n,e){for(;n.parentNode;){if(n.parentNode===e)return n;n=n.parentNode}},replaceWithSpans:function(n){return n.replace(c.regExpGlobal,P)}},H=function(n,e){var t,r,o=q.filterDescendants(E.fromDom(e),q.isMatch);w(o,function(e){var o=q.replaceWithSpans(B.value(e));for(r=n.dom.create("div",null,o);t=r.lastChild;)n.dom.insertAfter(t,e.dom());n.dom.remove(e.dom())})},L=function(n,e){var t=n.dom.select(c.selector,e);w(t,function(e){n.dom.remove(e,1)})},R=H,_=L,j=function(n){var e=n.getBody(),t=n.selection.getBookmark(),r=q.findParentElm(n.selection.getNode(),e);r=r!==undefined?r:e,L(n,r),H(n,r),n.selection.moveToBookmark(t)},z=function(n,e){var t,o=n.getBody(),u=n.selection;e.set(!e.get()),r(n,e.get()),t=u.getBookmark(),!0===e.get()?R(n,o):_(n,o),u.moveToBookmark(t)},G=function(n,e){n.addCommand("mceVisualChars",function(){z(n,e)})},W=tinymce.util.Tools.resolve("tinymce.util.Delay"),F=function(n,e){var t=W.debounce(function(){j(n)},300);!1!==n.settings.forced_root_block&&n.on("keydown",function(r){!0===e.get()&&(13===r.keyCode?j(n):t())})},I=function(n){return function(e){var t=e.control;n.on("VisualChars",function(n){t.active(n.state)})}};e.add("visualchars",function(e){var r=n(!1);return G(e,r),function(n){n.addButton("visualchars",{active:!1,title:"Show invisible characters",cmd:"mceVisualChars",onPostRender:I(n)}),n.addMenuItem("visualchars",{text:"Show invisible characters",cmd:"mceVisualChars",onPostRender:I(n),selectable:!0,context:"view",prependToContext:!0})}(e),F(e,r),t(r)})}();