text: /*! wysihtml - v0.6.0-beta1 (2018-03-22) */
  
  function capitalise(a){return a.length>0?a.charAt(0).toUpperCase()+a.slice(1):a}var wysihtml={version:"0.6.0-beta1",commands:{},dom:{},quirks:{},toolbar:{},lang:{},selection:{},views:{},editorExtenders:[],extendEditor:function(a){this.editorExtenders.push(a)},INVISIBLE_SPACE:"\ufeff",INVISIBLE_SPACE_REG_EXP:/\uFEFF/g,VOID_ELEMENTS:"area, base, br, col, embed, hr, img, input, keygen, link, meta, param, source, track, wbr",PERMITTED_PHRASING_CONTENT_ONLY:"h1, h2, h3, h4, h5, h6, p, pre",EMPTY_FUNCTION:function(){},ELEMENT_NODE:1,TEXT_NODE:3,BACKSPACE_KEY:8,ENTER_KEY:13,ESCAPE_KEY:27,SPACE_KEY:32,TAB_KEY:9,DELETE_KEY:46};wysihtml.polyfills=function(a,b){var c={normalizeHasCaretError:function(){if("createRange"in b&&"getSelection"in a){var c,d,e,f=window.pageYOffset,g=window.pageXOffset,h=b.createElement("div"),i=b.createTextNode("a"),j=b.createTextNode("a"),k=b.createTextNode("a"),l=b.createRange();return document.activeElement&&(1===document.activeElement.nodeType&&["INPUT","TEXTAREA","SELECT","BUTTON"].indexOf(document.activeElement.nodeName)>-1?c={type:"form",node:document.activeElement,start:document.activeElement.selectionStart,end:document.activeElement.selectionEnd}:(d=a.getSelection(),d&&d.anchorNode&&(c={type:"range",anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}))),h.setAttribute("contenteditable","true"),h.appendChild(i),h.appendChild(j),h.appendChild(k),b.body.appendChild(h),l.setStart(j,1),l.setEnd(j,1),d=a.getSelection(),d.removeAllRanges(),d.addRange(l),h.normalize(),d=a.getSelection(),e=1!==h.childNodes.length||d.anchorNode!==h.firstChild||2!==d.anchorOffset,h.parentNode.removeChild(h),d.removeAllRanges(),c&&("form"===c.type?("undefined"!=typeof c.start&&"undefined"!=typeof c.end&&c.node.setSelectionRange(c.start,c.end),c.node.focus()):"range"===c.type&&(l=b.createRange(),l.setStart(c.anchorNode,c.anchorOffset),l.setEnd(c.focusNode,c.focusOffset),d.addRange(l))),(f!==window.pageYOffset||g!==window.pageXOffset)&&a.scrollTo(g,f),e}},apply:function(){function d(){try{var b=new a.CustomEvent("cat",{detail:{foo:"bar"}});return"cat"===b.type&&"bar"===b.detail.foo}catch(c){}return!1}!function(a){a.matches=a.matches||a.mozMatchesSelector||a.msMatchesSelector||a.oMatchesSelector||a.webkitMatchesSelector||function(a){for(var b=this,c=(b.document||b.ownerDocument).querySelectorAll(a),d=0;c[d]&&c[d]!==b;)++d;return c[d]?!0:!1},a.closest=a.closest||function(a){for(var b=this;b&&!b.matches(a);)b=b.parentElement;return b},a.remove=a.remove||function(){this.parentNode&&this.parentNode.removeChild(this)}}(a.Element.prototype),"classList"in b.documentElement||!a.Object.defineProperty||"undefined"==typeof a.HTMLElement||a.Object.defineProperty(a.HTMLElement.prototype,"classList",{get:function(){function b(a){return function(b){var d=c.className.split(/\s+/),e=d.indexOf(b);a(d,e,b),c.className=d.join(" ")}}var c=this,d={add:b(function(a,b,c){~b||a.push(c)}),remove:b(function(a,b){~b&&a.splice(b,1)}),toggle:b(function(a,b,c){~b?a.splice(b,1):a.push(c)}),contains:function(a){return!!~c.className.split(/\s+/).indexOf(a)},item:function(a){return c.className.split(/\s+/)[a]||null}};return a.Object.defineProperty(d,"length",{get:function(){return c.className.split(/\s+/).length}}),d}});var e=function(a){var b=[];for(a=a.firstChild;a;a=a.nextSibling)3==a.nodeType?b.push(a):b=b.concat(e(a));return b},f=function(a){var b=a.ownerDocument,c=a;do{if(c===b)return!0;c=c.parentNode}while(c);return!1},g=function(){var b=(a.Node.prototype.normalize,function(){var b=e(this),c=this.ownerDocument.defaultView.getSelection(),d=c.anchorNode,g=c.anchorOffset,h=d&&1===d.nodeType&&d.childNodes.length>0?d.childNodes[g]:void 0,i=c.focusNode,j=c.focusOffset,k=i&&1===i.nodeType&&j>0?i.childNodes[j-1]:void 0,l=this.ownerDocument.createRange(),m=b.shift(),n=m?b.shift():null;for(k&&3===k.nodeType&&(i=k,j=k.nodeValue.length,k=void 0),h&&3===h.nodeType&&(d=h,g=0,h=void 0),(d===i&&g>j||d!==i&&d.compareDocumentPosition(i)&a.Node.DOCUMENT_POSITION_PRECEDING&&!(d.compareDocumentPosition(i)&a.Node.DOCUMENT_POSITION_CONTAINS))&&(i=[d,d=i][0],j=[g,g=j][0]);m&&n;)n.previousSibling&&n.previousSibling===m?(d===n&&(d=m,g=m.nodeValue.length+g),i===n&&(i=m,j=m.nodeValue.length+j),m.nodeValue=m.nodeValue+n.nodeValue,n.parentNode.removeChild(n),n=b.shift()):(m=n,n=b.shift());k&&(j=Array.prototype.indexOf.call(k.parentNode.childNodes,k)+1),h&&(g=Array.prototype.indexOf.call(h.parentNode.childNodes,h)),f(this)&&d&&d.parentNode&&i&&i.parentNode&&(l.setStart(d,g),l.setEnd(i,j),c.removeAllRanges(),c.addRange(l))});a.Node.prototype.normalize=b},h=function(){a.removeEventListener("load",h),"Node"in a&&"normalize"in a.Node.prototype&&c.normalizeHasCaretError()&&g()};"complete"!==b.readyState?a.addEventListener("load",h):h(),function(){function c(a,c){c=c||{bubbles:!1,cancelable:!1,detail:void 0};var d=b.createEvent("CustomEvent");return d.initCustomEvent(a,c.bubbles,c.cancelable,c.detail),d}!d()&&"CustomEvent"in a&&(c.prototype=a.Event.prototype,a.CustomEvent=c)}()}};return c},wysihtml.polyfills(window,document).apply();var Base=function(){};Base.extend=function(a,b){var c=Base.prototype.extend;Base._prototyping=!0;var d=new this;c.call(d,a),d.base=function(){},delete Base._prototyping;var e=d.constructor,f=d.constructor=function(){if(!Base._prototyping)if(this._constructing||this.constructor==f)this._constructing=!0,e.apply(this,arguments),delete this._constructing;else if(null!=arguments[0])return(arguments[0].extend||c).call(arguments[0],d)};return f.ancestor=this,f.extend=this.extend,f.forEach=this.forEach,f.implement=this.implement,f.prototype=d,f.toString=this.toString,f.valueOf=function(a){return"object"==a?f:e.valueOf()},c.call(f,b),"function"==typeof f.init&&f.init(),f},Base.prototype={extend:function(a,b){if(arguments.length>1){var c=this[a];if(c&&"function"==typeof b&&(!c.valueOf||c.valueOf()!=b.valueOf())&&/\bbase\b/.test(b)){var d=b.valueOf();b=function(){var a=this.base||Base.prototype.base;this.base=c;var b=d.apply(this,arguments);return this.base=a,b},b.valueOf=function(a){return"object"==a?b:d},b.toString=Base.toString}this[a]=b}else if(a){var e=Base.prototype.extend;Base._prototyping||"function"==typeof this||(e=this.extend||e);for(var f={toSource:null},g=["constructor","toString","valueOf"],h=Base._prototyping?0:1;i=g[h++];)a[i]!=f[i]&&e.call(this,i,a[i]);for(var i in a)f[i]||e.call(this,i,a[i])}return this}},Base=Base.extend({constructor:function(){this.extend(arguments[0])}},{ancestor:Object,version:"1.1",forEach:function(a,b,c){for(var d in a)void 0===this.prototype[d]&&b.call(c,a[d],d,a)},implement:function(){for(var a=0;a<arguments.length;a++)"function"==typeof arguments[a]?arguments[a](this.prototype):this.prototype.extend(arguments[a]);return this},toString:function(){return String(this.valueOf())}});var rangy;!function(){function a(a,b){var c=typeof a[b];return c==u||!(c!=t||!a[b])||"unknown"==c}function b(a,b){return!(typeof a[b]!=t||!a[b])}function c(a,b){return typeof a[b]!=v}function d(a){return function(b,c){for(var d=c.length;d--;)if(!a(b,c[d]))return!1;return!0}}function e(a){return a&&A(a,z)&&C(a,y)}function f(a){return b(a,"body")?a.body:a.getElementsByTagName("body")[0]}function g(b){typeof console!=v&&a(console,"log")&&console.log(b)}function h(a,b){F&&b?alert(a):g(a)}function i(a){H.initialized=!0,H.supported=!1,h("Rangy is not supported in this environment. Reason: "+a,H.config.alertOnFail)}function j(a){h("Rangy warning: "+a,H.config.alertOnWarn)}function k(a){return a.message||a.description||String(a)}function l(){if(F&&!H.initialized){var b,c=!1,d=!1;a(document,"createRange")&&(b=document.createRange(),A(b,x)&&C(b,w)&&(c=!0));var h=f(document);if(!h||"body"!=h.nodeName.toLowerCase())return void i("No body element found");if(h&&a(h,"createTextRange")&&(b=h.createTextRange(),e(b)&&(d=!0)),!c&&!d)return void i("Neither Range nor TextRange are available");H.initialized=!0,H.features={implementsDomRange:c,implementsTextRange:d};var j,l;for(var m in E)(j=E[m])instanceof p&&j.init(j,H);for(var n=0,o=K.length;o>n;++n)try{K[n](H)}catch(q){l="Rangy init listener threw an exception. Continuing. Detail: "+k(q),g(l)}}}function m(a,b,c){c&&(a+=" in module "+c.name),H.warn("DEPRECATED: "+a+" is deprecated. Please use "+b+" instead.")}function n(a,b,c,d){a[b]=function(){return m(b,c,d),a[c].apply(a,G.toArray(arguments))}}function o(a){a=a||window,l();for(var b=0,c=L.length;c>b;++b)L[b](a)}function p(a,b,c){this.name=a,this.dependencies=b,this.initialized=!1,this.supported=!1,this.initializer=c}function q(a,b,c){var d=new p(a,b,function(b){if(!b.initialized){b.initialized=!0;try{c(H,b),b.supported=!0}catch(d){var e="Module '"+a+"' failed to load: "+k(d);g(e),d.stack&&g(d.stack)}}});return E[a]=d,d}function r(){}function s(){}var t="object",u="function",v="undefined",w=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],x=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],y=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],z=["collapse","compareEndPoints","duplicate","moveToElementText","parentElement","select","setEndPoint","getBoundingClientRect"],A=d(a),B=d(b),C=d(c),D=[].forEach?function(a,b){a.forEach(b)}:function(a,b){for(var c=0,d=a.length;d>c;++c)b(a[c],c)},E={},F=typeof window!=v&&typeof document!=v,G={isHostMethod:a,isHostObject:b,isHostProperty:c,areHostMethods:A,areHostObjects:B,areHostProperties:C,isTextRange:e,getBody:f,forEach:D},H={version:"1.3.1-dev",initialized:!1,isBrowser:F,supported:!0,util:G,features:{},modules:E,config:{alertOnFail:!1,alertOnWarn:!1,preferTextRange:!1,autoInitialize:typeof rangyAutoInitialize==v?!0:rangyAutoInitialize}};H.fail=i,H.warn=j;var I;({}).hasOwnProperty?(G.extend=I=function(a,b,c){var d,e;for(var f in b)b.hasOwnProperty(f)&&(d=a[f],e=b[f],c&&null!==d&&"object"==typeof d&&null!==e&&"object"==typeof e&&I(d,e,!0),a[f]=e);return b.hasOwnProperty("toString")&&(a.toString=b.toString),a},G.createOptions=function(a,b){var c={};return I(c,b),a&&I(c,a),c}):i("hasOwnProperty not supported"),F||i("Rangy can only run in a browser"),function(){var a;if(F){var b=document.createElement("div");b.appendChild(document.createElement("span"));var c=[].slice;try{1==c.call(b.childNodes,0)[0].nodeType&&(a=function(a){return c.call(a,0)})}catch(d){}}a||(a=function(a){for(var b=[],c=0,d=a.length;d>c;++c)b[c]=a[c];return b}),G.toArray=a}();var J;F&&(a(document,"addEventListener")?J=function(a,b,c){a.addEventListener(b,c,!1)}:a(document,"attachEvent")?J=function(a,b,c){a.attachEvent("on"+b,c)}:i("Document does not have required addEventListener or attachEvent method"),G.addListener=J);var K=[];G.deprecationNotice=m,G.createAliasForDeprecatedMethod=n,H.init=l,H.addInitListener=function(a){H.initialized?a(H):K.push(a)};var L=[];H.addShimListener=function(a){L.push(a)},F&&(H.shim=H.createMissingNativeApi=o,n(H,"createMissingNativeApi","shim")),p.prototype={init:function(){for(var a,b,c=this.dependencies||[],d=0,e=c.length;e>d;++d){if(b=c[d],a=E[b],!(a&&a instanceof p))throw new Error("required module '"+b+"' not found");if(a.init(),!a.supported)throw new Error("required module '"+b+"' not supported")}this.initializer(this)},fail:function(a){throw this.initialized=!0,this.supported=!1,new Error(a)},warn:function(a){H.warn("Module "+this.name+": "+a)},deprecationNotice:function(a,b){H.warn("DEPRECATED: "+a+" in module "+this.name+" is deprecated. Please use "+b+" instead")},createError:function(a){return new Error("Error in Rangy "+this.name+" module: "+a)}},H.createModule=function(a){var b,c;2==arguments.length?(b=arguments[1],c=[]):(b=arguments[2],c=arguments[1]);var d=q(a,c,b);H.initialized&&H.supported&&d.init()},H.createCoreModule=function(a,b,c){q(a,b,c)},H.RangePrototype=r,H.rangePrototype=new r,H.selectionPrototype=new s,H.createCoreModule("DomUtil",[],function(a,b){function c(a){var b;return typeof a.namespaceURI==F||null===(b=a.namespaceURI)||"http://www.w3.org/1999/xhtml"==b}function d(a){var b=a.parentNode;return 1==b.nodeType?b:null}function e(a){for(var b=0;a=a.previousSibling;)++b;return b}function f(a){switch(a.nodeType){case 7:case 10:return 0;case 3:case 8:return a.length;default:return a.childNodes.length}}function g(a,b){var c,d=[];for(c=a;c;c=c.parentNode)d.push(c);for(c=b;c;c=c.parentNode)if(K(d,c))return c;return null}function h(a,b,c){for(var d=c?b:b.parentNode;d;){if(d===a)return!0;d=d.parentNode}return!1}function i(a,b){return h(a,b,!0)}function j(a,b,c){for(var d,e=c?a:a.parentNode;e;){if(d=e.parentNode,d===b)return e;e=d}return null}function k(a){var b=a.nodeType;return 3==b||4==b||8==b}function l(a){if(!a)return!1;var b=a.nodeType;return 3==b||8==b}function m(a,b){var c=b.nextSibling,d=b.parentNode;return c?d.insertBefore(a,c):d.appendChild(a),a}function n(a,b,c){var d=a.cloneNode(!1);if(d.deleteData(0,b),a.deleteData(b,a.length-b),m(d,a),c)for(var f,g=0;f=c[g++];)f.node==a&&f.offset>b?(f.node=d,f.offset-=b):f.node==a.parentNode&&f.offset>e(a)&&++f.offset;return d}function o(a){if(9==a.nodeType)return a;if(typeof a.ownerDocument!=F)return a.ownerDocument;if(typeof a.document!=F)return a.document;if(a.parentNode)return o(a.parentNode);throw b.createError("getDocument: no document found for node")}function p(a){var c=o(a);if(typeof c.defaultView!=F)return c.defaultView;if(typeof c.parentWindow!=F)return c.parentWindow;throw b.createError("Cannot get a window object for node")}function q(a){if(typeof a.contentDocument!=F)return a.contentDocument;if(typeof a.contentWindow!=F)return a.contentWindow.document;throw b.createError("getIframeDocument: No Document object found for iframe element")}function r(a){if(typeof a.contentWindow!=F)return a.contentWindow;if(typeof a.contentDocument!=F)return a.contentDocument.defaultView;throw b.createError("getIframeWindow: No Window object found for iframe element")}function s(a){return a&&G.isHostMethod(a,"setTimeout")&&G.isHostObject(a,"document")}function t(a,b,c){var d;if(a?G.isHostProperty(a,"nodeType")?d=1==a.nodeType&&"iframe"==a.tagName.toLowerCase()?q(a):o(a):s(a)&&(d=a.document):d=document,!d)throw b.createError(c+"(): Parameter must be a Window object or DOM node");return d}function u(a){for(var b;b=a.parentNode;)a=b;return a}function v(a,c,d,f){var h,i,k,l,m;if(a==d)return c===f?0:f>c?-1:1;if(h=j(d,a,!0))return c<=e(h)?-1:1;if(h=j(a,d,!0))return e(h)<f?-1:1;if(i=g(a,d),!i)throw new Error("comparePoints error: nodes have no common ancestor");if(k=a===i?i:j(a,i,!0),l=d===i?i:j(d,i,!0),k===l)throw b.createError("comparePoints got to case 4 and childA and childB are the same!");for(m=i.firstChild;m;){if(m===k)return-1;if(m===l)return 1;m=m.nextSibling}}function w(a){var b;try{return b=a.parentNode,!1}catch(c){return!0}}function x(a){if(!a)return"[No node]";if(L&&w(a))return"[Broken node]";if(k(a))return'"'+a.data+'"';if(1==a.nodeType){var b=a.id?' id="'+a.id+'"':"";return"<"+a.nodeName+b+">[index:"+e(a)+",length:"+a.childNodes.length+"]["+(a.innerHTML||"[innerHTML not supported]").slice(0,25)+"]"}return a.nodeName}function y(a){for(var b,c=o(a).createDocumentFragment();b=a.firstChild;)c.appendChild(b);return c}function z(a,b,c){var d=H(a),e=a.createElement("div");e.contentEditable=""+!!c,b&&(e.innerHTML=b);var f=d.firstChild;return f?d.insertBefore(e,f):d.appendChild(e),e}function A(a){return a.parentNode.removeChild(a)}function B(a){this.root=a,this._next=a}function C(a){return new B(a)}function D(a,b){this.node=a,this.offset=b}function E(a){this.code=this[a],this.codeName=a,this.message="DOMException: "+this.codeName}var F="undefined",G=a.util,H=G.getBody;G.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||b.fail("document missing a Node creation method"),G.isHostMethod(document,"getElementsByTagName")||b.fail("document missing getElementsByTagName method");var I=document.createElement("div");G.areHostMethods(I,["insertBefore","appendChild","cloneNode"]||!G.areHostObjects(I,["previousSibling","nextSibling","childNodes","parentNode"]))||b.fail("Incomplete Element implementation"),G.isHostProperty(I,"innerHTML")||b.fail("Element is missing innerHTML property");var J=document.createTextNode("test");G.areHostMethods(J,["splitText","deleteData","insertData","appendData","cloneNode"]||!G.areHostObjects(I,["previousSibling","nextSibling","childNodes","parentNode"])||!G.areHostProperties(J,["data"]))||b.fail("Incomplete Text Node implementation");var K=function(a,b){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1},L=!1;!function(){var b=document.createElement("b");b.innerHTML="1";var c=b.firstChild;b.innerHTML="<br />",L=w(c),a.features.crashyTextNodes=L}();var M;typeof window.getComputedStyle!=F?M=function(a,b){return p(a).getComputedStyle(a,null)[b]}:typeof document.documentElement.currentStyle!=F?M=function(a,b){return a.currentStyle?a.currentStyle[b]:""}:b.fail("No means of obtaining computed style properties found"),B.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var a,b,c=this._current=this._next;if(this._current)if(a=c.firstChild)this._next=a;else{for(b=null;c!==this.root&&!(b=c.nextSibling);)c=c.parentNode;this._next=b}return this._current},detach:function(){this._current=this._next=this.root=null}},D.prototype={equals:function(a){return!!a&&this.node===a.node&&this.offset==a.offset},inspect:function(){return"[DomPosition("+x(this.node)+":"+this.offset+")]"},toString:function(){return this.inspect()}},E.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11,INVALID_NODE_TYPE_ERR:24},E.prototype.toString=function(){return this.message},a.dom={arrayContains:K,isHtmlNamespace:c,parentElement:d,getNodeIndex:e,getNodeLength:f,getCommonAncestor:g,isAncestorOf:h,isOrIsAncestorOf:i,getClosestAncestorIn:j,isCharacterDataNode:k,isTextOrCommentNode:l,insertAfter:m,splitDataNode:n,getDocument:o,getWindow:p,getIframeWindow:r,getIframeDocument:q,getBody:H,isWindow:s,getContentDocument:t,getRootContainer:u,comparePoints:v,isBrokenNode:w,inspectNode:x,getComputedStyleProperty:M,createTestElement:z,removeNode:A,fragmentFromNodeChildren:y,createIterator:C,DomPosition:D},a.DOMException=E}),H.createCoreModule("DomRange",["DomUtil"],function(a,b){function c(a,b){return 3!=a.nodeType&&(P(a,b.startContainer)||P(a,b.endContainer))}function d(a){return a.document||Q(a.startContainer)}function e(a){return W(a.startContainer)}function f(a){return new L(a.parentNode,O(a))}function g(a){return new L(a.parentNode,O(a)+1)}function h(a,b,c){var d=11==a.nodeType?a.firstChild:a;return N(b)?c==b.length?J.insertAfter(a,b):b.parentNode.insertBefore(a,0==c?b:S(b,c)):c>=b.childNodes.length?b.appendChild(a):b.insertBefore(a,b.childNodes[c]),d}function i(a,b,c){if(z(a),z(b),d(b)!=d(a))throw new M("WRONG_DOCUMENT_ERR");var e=R(a.startContainer,a.startOffset,b.endContainer,b.endOffset),f=R(a.endContainer,a.endOffset,b.startContainer,b.startOffset);return c?0>=e&&f>=0:0>e&&f>0}function j(a){for(var b,c,e,f=d(a.range).createDocumentFragment();c=a.next();){if(b=a.isPartiallySelectedSubtree(),c=c.cloneNode(!b),b&&(e=a.getSubtreeIterator(),c.appendChild(j(e)),e.detach()),10==c.nodeType)throw new M("HIERARCHY_REQUEST_ERR");f.appendChild(c)}return f}function k(a,b,c){var d,e;c=c||{stop:!1};for(var f,g;f=a.next();)if(a.isPartiallySelectedSubtree()){if(b(f)===!1)return void(c.stop=!0);if(g=a.getSubtreeIterator(),k(g,b,c),g.detach(),c.stop)return}else for(d=J.createIterator(f);e=d.next();)if(b(e)===!1)return void(c.stop=!0)}function l(a){for(var b;a.next();)a.isPartiallySelectedSubtree()?(b=a.getSubtreeIterator(),l(b),b.detach()):a.remove()}function m(a){for(var b,c,e=d(a.range).createDocumentFragment();b=a.next();){if(a.isPartiallySelectedSubtree()?(b=b.cloneNode(!1),c=a.getSubtreeIterator(),b.appendChild(m(c)),c.detach()):a.remove(),10==b.nodeType)throw new M("HIERARCHY_REQUEST_ERR");e.appendChild(b)}return e}function n(a,b,c){var d,e=!(!b||!b.length),f=!!c;e&&(d=new RegExp("^("+b.join("|")+")$"));var g=[];return k(new p(a,!1),function(b){if((!e||d.test(b.nodeType))&&(!f||c(b))){var h=a.startContainer;if(b!=h||!N(h)||a.startOffset!=h.length){var i=a.endContainer;b==i&&N(i)&&0==a.endOffset||g.push(b)}}}),g}function o(a){var b="undefined"==typeof a.getName?"Range":a.getName();return"["+b+"("+J.inspectNode(a.startContainer)+":"+a.startOffset+", "+J.inspectNode(a.endContainer)+":"+a.endOffset+")]"}function p(a,b){if(this.range=a,this.clonePartiallySelectedTextNodes=b,!a.collapsed){this.sc=a.startContainer,this.so=a.startOffset,this.ec=a.endContainer,this.eo=a.endOffset;var c=a.commonAncestorContainer;this.sc===this.ec&&N(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==c||N(this.sc)?T(this.sc,c,!0):this.sc.childNodes[this.so],this._last=this.ec!==c||N(this.ec)?T(this.ec,c,!0):this.ec.childNodes[this.eo-1])}}function q(a){return function(b,c){for(var d,e=c?b:b.parentNode;e;){if(d=e.nodeType,V(a,d))return e;e=e.parentNode}return null}}function r(a,b){if(ea(a,b))throw new M("INVALID_NODE_TYPE_ERR")}function s(a,b){if(!V(b,a.nodeType))throw new M("INVALID_NODE_TYPE_ERR")}function t(a,b){if(0>b||b>(N(a)?a.length:a.childNodes.length))throw new M("INDEX_SIZE_ERR")}function u(a,b){if(ca(a,!0)!==ca(b,!0))throw new M("WRONG_DOCUMENT_ERR")}function v(a){if(da(a,!0))throw new M("NO_MODIFICATION_ALLOWED_ERR")}function w(a,b){if(!a)throw new M(b)}function x(a,b){return b<=(N(a)?a.length:a.childNodes.length)}function y(a){return!!a.startContainer&&!!a.endContainer&&!(X&&(J.isBrokenNode(a.startContainer)||J.isBrokenNode(a.endContainer)))&&W(a.startContainer)==W(a.endContainer)&&x(a.startContainer,a.startOffset)&&x(a.endContainer,a.endOffset)}function z(a){if(!y(a))throw new Error("Range error: Range is not valid. This usually happens after DOM mutation. Range: ("+a.inspect()+")")}function A(a,b){z(a);var c=a.startContainer,d=a.startOffset,e=a.endContainer,f=a.endOffset,g=c===e;N(e)&&f>0&&f<e.length&&S(e,f,b),N(c)&&d>0&&d<c.length&&(c=S(c,d,b),g?(f-=d,e=c):e==c.parentNode&&f>=O(c)&&f++,d=0),a.setStartAndEnd(c,d,e,f)}function B(a){z(a);var b=a.commonAncestorContainer.parentNode.cloneNode(!1);return b.appendChild(a.cloneContents()),b.innerHTML}function C(a){a.START_TO_START=ka,a.START_TO_END=la,a.END_TO_END=ma,a.END_TO_START=na,a.NODE_BEFORE=oa,a.NODE_AFTER=pa,a.NODE_BEFORE_AND_AFTER=qa,a.NODE_INSIDE=ra}function D(a){C(a),C(a.prototype)}function E(a,b){return function(){z(this);var c,d,e=this.startContainer,f=this.startOffset,h=this.commonAncestorContainer,i=new p(this,!0);e!==h&&(c=T(e,h,!0),d=g(c),e=d.node,f=d.offset),k(i,v),i.reset();var j=a(i);return i.detach(),b(this,e,f,e,f),j}}function F(b,d){function e(a,b){return function(c){s(c,Z),s(W(c),$);var d=(a?f:g)(c);(b?h:i)(this,d.node,d.offset)}}function h(a,b,c){var e=a.endContainer,f=a.endOffset;(b!==a.startContainer||c!==a.startOffset)&&((W(b)!=W(e)||1==R(b,c,e,f))&&(e=b,f=c),d(a,b,c,e,f))}function i(a,b,c){var e=a.startContainer,f=a.startOffset;(b!==a.endContainer||c!==a.endOffset)&&((W(b)!=W(e)||-1==R(b,c,e,f))&&(e=b,f=c),d(a,e,f,b,c))}var j=function(){};j.prototype=a.rangePrototype,b.prototype=new j,K.extend(b.prototype,{setStart:function(a,b){r(a,!0),t(a,b),h(this,a,b)},setEnd:function(a,b){r(a,!0),t(a,b),i(this,a,b)},setStartAndEnd:function(){var a=arguments,b=a[0],c=a[1],e=b,f=c;switch(a.length){case 3:f=a[2];break;case 4:e=a[2],f=a[3]}d(this,b,c,e,f)},setBoundary:function(a,b,c){this["set"+(c?"Start":"End")](a,b)},setStartBefore:e(!0,!0),setStartAfter:e(!1,!0),setEndBefore:e(!0,!1),setEndAfter:e(!1,!1),collapse:function(a){z(this),a?d(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):d(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(a){r(a,!0),d(this,a,0,a,U(a))},selectNode:function(a){r(a,!1),s(a,Z);var b=f(a),c=g(a);d(this,b.node,b.offset,c.node,c.offset)},extractContents:E(m,d),deleteContents:E(l,d),canSurroundContents:function(){z(this),v(this.startContainer),v(this.endContainer);var a=new p(this,!0),b=a._first&&c(a._first,this)||a._last&&c(a._last,this);return a.detach(),!b},splitBoundaries:function(){A(this)},splitBoundariesPreservingPositions:function(a){A(this,a)},normalizeBoundaries:function(){z(this);var a,b=this.startContainer,c=this.startOffset,e=this.endContainer,f=this.endOffset,g=function(a){var b=a.nextSibling;b&&b.nodeType==a.nodeType&&(e=a,f=a.length,a.appendData(b.data),Y(b))},h=function(a){var d=a.previousSibling;if(d&&d.nodeType==a.nodeType){b=a;var g=a.length;if(c=d.length,a.insertData(0,d.data),Y(d),b==e)f+=c,e=b;else if(e==a.parentNode){var h=O(a);f==h?(e=a,f=g):f>h&&f--}}},i=!0;if(N(e))f==e.length?g(e):0==f&&(a=e.previousSibling,a&&a.nodeType==e.nodeType&&(f=a.length,b==e&&(i=!1),a.appendData(e.data),Y(e),e=a));else{if(f>0){var j=e.childNodes[f-1];j&&N(j)&&g(j)}i=!this.collapsed}if(i){if(N(b))0==c?h(b):c==b.length&&(a=b.nextSibling,a&&a.nodeType==b.nodeType&&(e==a&&(e=b,f+=b.length),b.appendData(a.data),Y(a)));else if(c<b.childNodes.length){var k=b.childNodes[c];k&&N(k)&&h(k)}}else b=e,c=f;d(this,b,c,e,f)},collapseToPoint:function(a,b){r(a,!0),t(a,b),this.setStartAndEnd(a,b)}}),D(b)}function G(a){a.collapsed=a.startContainer===a.endContainer&&a.startOffset===a.endOffset,a.commonAncestorContainer=a.collapsed?a.startContainer:J.getCommonAncestor(a.startContainer,a.endContainer)}function H(a,b,c,d,e){a.startContainer=b,a.startOffset=c,a.endContainer=d,a.endOffset=e,a.document=J.getDocument(b),G(a)}function I(a){this.startContainer=a,this.startOffset=0,this.endContainer=a,this.endOffset=0,this.document=a,G(this)}var J=a.dom,K=a.util,L=J.DomPosition,M=a.DOMException,N=J.isCharacterDataNode,O=J.getNodeIndex,P=J.isOrIsAncestorOf,Q=J.getDocument,R=J.comparePoints,S=J.splitDataNode,T=J.getClosestAncestorIn,U=J.getNodeLength,V=J.arrayContains,W=J.getRootContainer,X=a.features.crashyTextNodes,Y=J.removeNode;p.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=null,this._next=this._first},hasNext:function(){return!!this._next},next:function(){var a=this._current=this._next;return a&&(this._next=a!==this._last?a.nextSibling:null,N(a)&&this.clonePartiallySelectedTextNodes&&(a===this.ec&&(a=a.cloneNode(!0)).deleteData(this.eo,a.length-this.eo),this._current===this.sc&&(a=a.cloneNode(!0)).deleteData(0,this.so))),a},remove:function(){var a,b,c=this._current;!N(c)||c!==this.sc&&c!==this.ec?c.parentNode&&Y(c):(a=c===this.sc?this.so:0,b=c===this.ec?this.eo:c.length,a!=b&&c.deleteData(a,b-a))},isPartiallySelectedSubtree:function(){var a=this._current;return c(a,this.range)},getSubtreeIterator:function(){var a;if(this.isSingleCharacterDataNode)a=this.range.cloneRange(),a.collapse(!1);else{a=new I(d(this.range));var b=this._current,c=b,e=0,f=b,g=U(b);P(b,this.sc)&&(c=this.sc,e=this.so),P(b,this.ec)&&(f=this.ec,g=this.eo),H(a,c,e,f,g)}return new p(a,this.clonePartiallySelectedTextNodes)},detach:function(){this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}};var Z=[1,3,4,5,7,8,10],$=[2,9,11],_=[5,6,10,12],aa=[1,3,4,5,7,8,10,11],ba=[1,3,4,5,7,8],ca=q([9,11]),da=q(_),ea=q([6,10,12]),fa=document.createElement("style"),ga=!1;try{fa.innerHTML="<b>x</b>",ga=3==fa.firstChild.nodeType}catch(ha){}a.features.htmlParsingConforms=ga;var ia=ga?function(a){var b=this.startContainer,c=Q(b);if(!b)throw new M("INVALID_STATE_ERR");var d=null;return 1==b.nodeType?d=b:N(b)&&(d=J.parentElement(b)),d=null===d||"HTML"==d.nodeName&&J.isHtmlNamespace(Q(d).documentElement)&&J.isHtmlNamespace(d)?c.createElement("body"):d.cloneNode(!1),d.innerHTML=a,J.fragmentFromNodeChildren(d)}:function(a){var b=d(this),c=b.createElement("body");return c.innerHTML=a,J.fragmentFromNodeChildren(c)},ja=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],ka=0,la=1,ma=2,na=3,oa=0,pa=1,qa=2,ra=3;K.extend(a.rangePrototype,{compareBoundaryPoints:function(a,b){z(this),u(this.startContainer,b.startContainer);var c,d,e,f,g=a==na||a==ka?"start":"end",h=a==la||a==ka?"start":"end";return c=this[g+"Container"],d=this[g+"Offset"],e=b[h+"Container"],f=b[h+"Offset"],R(c,d,e,f)},insertNode:function(a){if(z(this),s(a,aa),v(this.startContainer),P(a,this.startContainer))throw new M("HIERARCHY_REQUEST_ERR");var b=h(a,this.startContainer,this.startOffset);this.setStartBefore(b)},cloneContents:function(){z(this);var a,b;if(this.collapsed)return d(this).createDocumentFragment();if(this.startContainer===this.endContainer&&N(this.startContainer))return a=this.startContainer.cloneNode(!0),a.data=a.data.slice(this.startOffset,this.endOffset),b=d(this).createDocumentFragment(),b.appendChild(a),b;var c=new p(this,!0);return a=j(c),c.detach(),a},canSurroundContents:function(){z(this),v(this.startContainer),v(this.endContainer);var a=new p(this,!0),b=a._first&&c(a._first,this)||a._last&&c(a._last,this);return a.detach(),!b},surroundContents:function(a){if(s(a,ba),!this.canSurroundContents())throw new M("INVALID_STATE_ERR");var b=this.extractContents();if(a.hasChildNodes())for(;a.lastChild;)a.removeChild(a.lastChild);h(a,this.startContainer,this.startOffset),a.appendChild(b),this.selectNode(a)},cloneRange:function(){z(this);for(var a,b=new I(d(this)),c=ja.length;c--;)a=ja[c],b[a]=this[a];return b},toString:function(){z(this);var a=this.startContainer;if(a===this.endContainer&&N(a))return 3==a.nodeType||4==a.nodeType?a.data.slice(this.startOffset,this.endOffset):"";var b=[],c=new p(this,!0);return k(c,function(a){(3==a.nodeType||4==a.nodeType)&&b.push(a.data)}),c.detach(),b.join("")},compareNode:function(a){z(this);var b=a.parentNode,c=O(a);if(!b)throw new M("NOT_FOUND_ERR");var d=this.comparePoint(b,c),e=this.comparePoint(b,c+1);return 0>d?e>0?qa:oa:e>0?pa:ra},comparePoint:function(a,b){return z(this),w(a,"HIERARCHY_REQUEST_ERR"),u(a,this.startContainer),R(a,b,this.startContainer,this.startOffset)<0?-1:R(a,b,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:ia,toHtml:function(){return B(this)},intersectsNode:function(a,b){if(z(this),W(a)!=e(this))return!1;var c=a.parentNode,d=O(a);if(!c)return!0;var f=R(c,d,this.endContainer,this.endOffset),g=R(c,d+1,this.startContainer,this.startOffset);return b?0>=f&&g>=0:0>f&&g>0},isPointInRange:function(a,b){return z(this),w(a,"HIERARCHY_REQUEST_ERR"),u(a,this.startContainer),R(a,b,this.startContainer,this.startOffset)>=0&&R(a,b,this.endContainer,this.endOffset)<=0},intersectsRange:function(a){return i(this,a,!1)},intersectsOrTouchesRange:function(a){return i(this,a,!0)},intersection:function(a){if(this.intersectsRange(a)){var b=R(this.startContainer,this.startOffset,a.startContainer,a.startOffset),c=R(this.endContainer,this.endOffset,a.endContainer,a.endOffset),d=this.cloneRange();return-1==b&&d.setStart(a.startContainer,a.startOffset),1==c&&d.setEnd(a.endContainer,a.endOffset),d}return null},union:function(a){if(this.intersectsOrTouchesRange(a)){var b=this.cloneRange();return-1==R(a.startContainer,a.startOffset,this.startContainer,this.startOffset)&&b.setStart(a.startContainer,a.startOffset),1==R(a.endContainer,a.endOffset,this.endContainer,this.endOffset)&&b.setEnd(a.endContainer,a.endOffset),b}throw new M("Ranges do not intersect")},containsNode:function(a,b){return b?this.intersectsNode(a,!1):this.compareNode(a)==ra},containsNodeContents:function(a){return this.comparePoint(a,0)>=0&&this.comparePoint(a,U(a))<=0},containsRange:function(a){var b=this.intersection(a);return null!==b&&a.equals(b)},containsNodeText:function(a){var b=this.cloneRange();b.selectNode(a);var c=b.getNodes([3]);if(c.length>0){b.setStart(c[0],0);var d=c.pop();return b.setEnd(d,d.length),
  this.containsRange(b)}return this.containsNodeContents(a)},getNodes:function(a,b){return z(this),n(this,a,b)},getDocument:function(){return d(this)},collapseBefore:function(a){this.setEndBefore(a),this.collapse(!1)},collapseAfter:function(a){this.setStartAfter(a),this.collapse(!0)},getBookmark:function(b){var c=d(this),e=a.createRange(c);b=b||J.getBody(c),e.selectNodeContents(b);var f=this.intersection(e),g=0,h=0;return f&&(e.setEnd(f.startContainer,f.startOffset),g=e.toString().length,h=g+f.toString().length),{start:g,end:h,containerNode:b}},moveToBookmark:function(a){var b=a.containerNode,c=0;this.setStart(b,0),this.collapse(!0);for(var d,e,f,g,h=[b],i=!1,j=!1;!j&&(d=h.pop());)if(3==d.nodeType)e=c+d.length,!i&&a.start>=c&&a.start<=e&&(this.setStart(d,a.start-c),i=!0),i&&a.end>=c&&a.end<=e&&(this.setEnd(d,a.end-c),j=!0),c=e;else for(g=d.childNodes,f=g.length;f--;)h.push(g[f])},getName:function(){return"DomRange"},equals:function(a){return I.rangesEqual(this,a)},isValid:function(){return y(this)},inspect:function(){return o(this)},detach:function(){}}),F(I,H),K.extend(I,{rangeProperties:ja,RangeIterator:p,copyComparisonConstants:D,createPrototypeRange:F,inspect:o,toHtml:B,getRangeDocument:d,rangesEqual:function(a,b){return a.startContainer===b.startContainer&&a.startOffset===b.startOffset&&a.endContainer===b.endContainer&&a.endOffset===b.endOffset}}),a.DomRange=I}),H.createCoreModule("WrappedRange",["DomRange"],function(a,b){var c,d,e=a.dom,f=a.util,g=e.DomPosition,h=a.DomRange,i=e.getBody,j=e.getContentDocument,k=e.isCharacterDataNode;if(a.features.implementsDomRange&&!function(){function d(a){for(var b,c=m.length;c--;)b=m[c],a[b]=a.nativeRange[b];a.collapsed=a.startContainer===a.endContainer&&a.startOffset===a.endOffset}function g(a,b,c,d,e){var f=a.startContainer!==b||a.startOffset!=c,g=a.endContainer!==d||a.endOffset!=e,h=!a.equals(a.nativeRange);(f||g||h)&&(a.setEnd(d,e),a.setStart(b,c))}var k,l,m=h.rangeProperties;c=function(a){if(!a)throw b.createError("WrappedRange: Range must be specified");this.nativeRange=a,d(this)},h.createPrototypeRange(c,g),k=c.prototype,k.selectNode=function(a){this.nativeRange.selectNode(a),d(this)},k.cloneContents=function(){return this.nativeRange.cloneContents()},k.surroundContents=function(a){this.nativeRange.surroundContents(a),d(this)},k.collapse=function(a){this.nativeRange.collapse(a),d(this)},k.cloneRange=function(){return new c(this.nativeRange.cloneRange())},k.refresh=function(){d(this)},k.toString=function(){return this.nativeRange.toString()};var n=document.createTextNode("test");i(document).appendChild(n);var o=document.createRange();o.setStart(n,0),o.setEnd(n,0);try{o.setStart(n,1),k.setStart=function(a,b){this.nativeRange.setStart(a,b),d(this)},k.setEnd=function(a,b){this.nativeRange.setEnd(a,b),d(this)},l=function(a){return function(b){this.nativeRange[a](b),d(this)}}}catch(p){k.setStart=function(a,b){try{this.nativeRange.setStart(a,b)}catch(c){this.nativeRange.setEnd(a,b),this.nativeRange.setStart(a,b)}d(this)},k.setEnd=function(a,b){try{this.nativeRange.setEnd(a,b)}catch(c){this.nativeRange.setStart(a,b),this.nativeRange.setEnd(a,b)}d(this)},l=function(a,b){return function(c){try{this.nativeRange[a](c)}catch(e){this.nativeRange[b](c),this.nativeRange[a](c)}d(this)}}}k.setStartBefore=l("setStartBefore","setEndBefore"),k.setStartAfter=l("setStartAfter","setEndAfter"),k.setEndBefore=l("setEndBefore","setStartBefore"),k.setEndAfter=l("setEndAfter","setStartAfter"),k.selectNodeContents=function(a){this.setStartAndEnd(a,0,e.getNodeLength(a))},o.selectNodeContents(n),o.setEnd(n,3);var q=document.createRange();q.selectNodeContents(n),q.setEnd(n,4),q.setStart(n,2),-1==o.compareBoundaryPoints(o.START_TO_END,q)&&1==o.compareBoundaryPoints(o.END_TO_START,q)?k.compareBoundaryPoints=function(a,b){return b=b.nativeRange||b,a==b.START_TO_END?a=b.END_TO_START:a==b.END_TO_START&&(a=b.START_TO_END),this.nativeRange.compareBoundaryPoints(a,b)}:k.compareBoundaryPoints=function(a,b){return this.nativeRange.compareBoundaryPoints(a,b.nativeRange||b)};var r=document.createElement("div");r.innerHTML="123";var s=r.firstChild,t=i(document);t.appendChild(r),o.setStart(s,1),o.setEnd(s,2),o.deleteContents(),"13"==s.data&&(k.deleteContents=function(){this.nativeRange.deleteContents(),d(this)},k.extractContents=function(){var a=this.nativeRange.extractContents();return d(this),a}),t.removeChild(r),t=null,f.isHostMethod(o,"createContextualFragment")&&(k.createContextualFragment=function(a){return this.nativeRange.createContextualFragment(a)}),i(document).removeChild(n),k.getName=function(){return"WrappedRange"},a.WrappedRange=c,a.createNativeRange=function(a){return a=j(a,b,"createNativeRange"),a.createRange()}}(),a.features.implementsTextRange){var l=function(a){var b=a.parentElement(),c=a.duplicate();c.collapse(!0);var d=c.parentElement();c=a.duplicate(),c.collapse(!1);var f=c.parentElement(),g=d==f?d:e.getCommonAncestor(d,f);return g==b?g:e.getCommonAncestor(b,g)},m=function(a){return 0==a.compareEndPoints("StartToEnd",a)},n=function(a,b,c,d,f){var h=a.duplicate();h.collapse(c);var i=h.parentElement();if(e.isOrIsAncestorOf(b,i)||(i=b),!i.canHaveHTML){var j=new g(i.parentNode,e.getNodeIndex(i));return{boundaryPosition:j,nodeInfo:{nodeIndex:j.offset,containerElement:j.node}}}var l=e.getDocument(i).createElement("span");l.parentNode&&e.removeNode(l);for(var m,n,o,p,q,r=c?"StartToStart":"StartToEnd",s=f&&f.containerElement==i?f.nodeIndex:0,t=i.childNodes.length,u=t,v=u;;){if(v==t?i.appendChild(l):i.insertBefore(l,i.childNodes[v]),h.moveToElementText(l),m=h.compareEndPoints(r,a),0==m||s==u)break;if(-1==m){if(u==s+1)break;s=v}else u=u==s+1?s:v;v=Math.floor((s+u)/2),i.removeChild(l)}if(q=l.nextSibling,-1==m&&q&&k(q)){h.setEndPoint(c?"EndToStart":"EndToEnd",a);var w;if(/[\r\n]/.test(q.data)){var x=h.duplicate(),y=x.text.replace(/\r\n/g,"\r").length;for(w=x.moveStart("character",y);-1==(m=x.compareEndPoints("StartToEnd",x));)w++,x.moveStart("character",1)}else w=h.text.length;p=new g(q,w)}else n=(d||!c)&&l.previousSibling,o=(d||c)&&l.nextSibling,p=o&&k(o)?new g(o,0):n&&k(n)?new g(n,n.data.length):new g(i,e.getNodeIndex(l));return e.removeNode(l),{boundaryPosition:p,nodeInfo:{nodeIndex:v,containerElement:i}}},o=function(a,b){var c,d,f,g,h=a.offset,j=e.getDocument(a.node),l=i(j).createTextRange(),m=k(a.node);return m?(c=a.node,d=c.parentNode):(g=a.node.childNodes,c=h<g.length?g[h]:null,d=a.node),f=j.createElement("span"),f.innerHTML="&#feff;",c?d.insertBefore(f,c):d.appendChild(f),l.moveToElementText(f),l.collapse(!b),d.removeChild(f),m&&l[b?"moveStart":"moveEnd"]("character",h),l};d=function(a){this.textRange=a,this.refresh()},d.prototype=new h(document),d.prototype.refresh=function(){var a,b,c,d=l(this.textRange);m(this.textRange)?b=a=n(this.textRange,d,!0,!0).boundaryPosition:(c=n(this.textRange,d,!0,!1),a=c.boundaryPosition,b=n(this.textRange,d,!1,!1,c.nodeInfo).boundaryPosition),this.setStart(a.node,a.offset),this.setEnd(b.node,b.offset)},d.prototype.getName=function(){return"WrappedTextRange"},h.copyComparisonConstants(d);var p=function(a){if(a.collapsed)return o(new g(a.startContainer,a.startOffset),!0);var b=o(new g(a.startContainer,a.startOffset),!0),c=o(new g(a.endContainer,a.endOffset),!1),d=i(h.getRangeDocument(a)).createTextRange();return d.setEndPoint("StartToStart",b),d.setEndPoint("EndToEnd",c),d};if(d.rangeToTextRange=p,d.prototype.toTextRange=function(){return p(this)},a.WrappedTextRange=d,!a.features.implementsDomRange||a.config.preferTextRange){var q=function(a){return a("return this;")()}(Function);"undefined"==typeof q.Range&&(q.Range=d),a.createNativeRange=function(a){return a=j(a,b,"createNativeRange"),i(a).createTextRange()},a.WrappedRange=d}}a.createRange=function(c){return c=j(c,b,"createRange"),new a.WrappedRange(a.createNativeRange(c))},a.createRangyRange=function(a){return a=j(a,b,"createRangyRange"),new h(a)},f.createAliasForDeprecatedMethod(a,"createIframeRange","createRange"),f.createAliasForDeprecatedMethod(a,"createIframeRangyRange","createRangyRange"),a.addShimListener(function(b){var c=b.document;"undefined"==typeof c.createRange&&(c.createRange=function(){return a.createRange(c)}),c=b=null})}),H.createCoreModule("WrappedSelection",["DomRange","WrappedRange"],function(a,b){function c(a){return"string"==typeof a?/^backward(s)?$/i.test(a):!!a}function d(a,c){if(a){if(C.isWindow(a))return a;if(a instanceof r)return a.win;var d=C.getContentDocument(a,b,c);return C.getWindow(d)}return window}function e(a){return d(a,"getWinSelection").getSelection()}function f(a){return d(a,"getDocSelection").document.selection}function g(a){var b=!1;return a.anchorNode&&(b=1==C.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset)),b}function h(a,b,c){var d=c?"end":"start",e=c?"start":"end";a.anchorNode=b[d+"Container"],a.anchorOffset=b[d+"Offset"],a.focusNode=b[e+"Container"],a.focusOffset=b[e+"Offset"]}function i(a){var b=a.nativeSelection;a.anchorNode=b.anchorNode,a.anchorOffset=b.anchorOffset,a.focusNode=b.focusNode,a.focusOffset=b.focusOffset}function j(a){a.anchorNode=a.focusNode=null,a.anchorOffset=a.focusOffset=0,a.rangeCount=0,a.isCollapsed=!0,a._ranges.length=0}function k(b){var c;return b instanceof F?(c=a.createNativeRange(b.getDocument()),c.setEnd(b.endContainer,b.endOffset),c.setStart(b.startContainer,b.startOffset)):b instanceof G?c=b.nativeRange:J.implementsDomRange&&b instanceof C.getWindow(b.startContainer).Range&&(c=b),c}function l(a){if(!a.length||1!=a[0].nodeType)return!1;for(var b=1,c=a.length;c>b;++b)if(!C.isAncestorOf(a[0],a[b]))return!1;return!0}function m(a){var c=a.getNodes();if(!l(c))throw b.createError("getSingleElementFromRange: range "+a.inspect()+" did not consist of a single element");return c[0]}function n(a){return!!a&&"undefined"!=typeof a.text}function o(a,b){var c=new G(b);a._ranges=[c],h(a,c,!1),a.rangeCount=1,a.isCollapsed=c.collapsed}function p(b){if(b._ranges.length=0,"None"==b.docSelection.type)j(b);else{var c=b.docSelection.createRange();if(n(c))o(b,c);else{b.rangeCount=c.length;for(var d,e=L(c.item(0)),f=0;f<b.rangeCount;++f)d=a.createRange(e),d.selectNode(c.item(f)),b._ranges.push(d);b.isCollapsed=1==b.rangeCount&&b._ranges[0].collapsed,h(b,b._ranges[b.rangeCount-1],!1)}}}function q(a,c){for(var d=a.docSelection.createRange(),e=m(c),f=L(d.item(0)),g=M(f).createControlRange(),h=0,i=d.length;i>h;++h)g.add(d.item(h));try{g.add(e)}catch(j){throw b.createError("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}g.select(),p(a)}function r(a,b,c){this.nativeSelection=a,this.docSelection=b,this._ranges=[],this.win=c,this.refresh()}function s(a){a.win=a.anchorNode=a.focusNode=a._ranges=null,a.rangeCount=a.anchorOffset=a.focusOffset=0,a.detached=!0}function t(a,b){for(var c,d,e=ba.length;e--;)if(c=ba[e],d=c.selection,"deleteAll"==b)s(d);else if(c.win==a)return"delete"==b?(ba.splice(e,1),!0):d;return"deleteAll"==b&&(ba.length=0),null}function u(a,c){for(var d,e=L(c[0].startContainer),f=M(e).createControlRange(),g=0,h=c.length;h>g;++g){d=m(c[g]);try{f.add(d)}catch(i){throw b.createError("setRanges(): Element within one of the specified Ranges could not be added to control selection (does it have layout?)")}}f.select(),p(a)}function v(a,b){if(a.win.document!=L(b))throw new H("WRONG_DOCUMENT_ERR")}function w(b){return function(c,d){var e;this.rangeCount?(e=this.getRangeAt(0),e["set"+(b?"Start":"End")](c,d)):(e=a.createRange(this.win.document),e.setStartAndEnd(c,d)),this.setSingleRange(e,this.isBackward())}}function x(a){var b=[],c=new I(a.anchorNode,a.anchorOffset),d=new I(a.focusNode,a.focusOffset),e="function"==typeof a.getName?a.getName():"Selection";if("undefined"!=typeof a.rangeCount)for(var f=0,g=a.rangeCount;g>f;++f)b[f]=F.inspect(a.getRangeAt(f));return"["+e+"(Ranges: "+b.join(", ")+")(anchor: "+c.inspect()+", focus: "+d.inspect()+"]"}a.config.checkSelectionRanges=!0;var y,z,A="boolean",B="number",C=a.dom,D=a.util,E=D.isHostMethod,F=a.DomRange,G=a.WrappedRange,H=a.DOMException,I=C.DomPosition,J=a.features,K="Control",L=C.getDocument,M=C.getBody,N=F.rangesEqual,O=E(window,"getSelection"),P=D.isHostObject(document,"selection");J.implementsWinGetSelection=O,J.implementsDocSelection=P;var Q=P&&(!O||a.config.preferTextRange);if(Q)y=f,a.isSelectionValid=function(a){var b=d(a,"isSelectionValid").document,c=b.selection;return"None"!=c.type||L(c.createRange().parentElement())==b};else{if(!O)return b.fail("Neither document.selection or window.getSelection() detected."),!1;y=e,a.isSelectionValid=function(){return!0}}a.getNativeSelection=y;var R=y();if(!R)return b.fail("Native selection was null (possibly issue 138?)"),!1;var S=a.createNativeRange(document),T=M(document),U=D.areHostProperties(R,["anchorNode","focusNode","anchorOffset","focusOffset"]);J.selectionHasAnchorAndFocus=U;var V=E(R,"extend");J.selectionHasExtend=V;var W=typeof R.rangeCount==B;J.selectionHasRangeCount=W;var X=!1,Y=!0,Z=V?function(b,c){var d=F.getRangeDocument(c),e=a.createRange(d);e.collapseToPoint(c.endContainer,c.endOffset),b.addRange(k(e)),b.extend(c.startContainer,c.startOffset)}:null;D.areHostMethods(R,["addRange","getRangeAt","removeAllRanges"])&&typeof R.rangeCount==B&&J.implementsDomRange&&!function(){var b=window.getSelection();if(b){for(var c=b.rangeCount,d=c>1,e=[],f=g(b),h=0;c>h;++h)e[h]=b.getRangeAt(h);var i=C.createTestElement(document,"",!1),j=i.appendChild(document.createTextNode("   ")),k=document.createRange();if(k.setStart(j,1),k.collapse(!0),b.removeAllRanges(),b.addRange(k),Y=1==b.rangeCount,b.removeAllRanges(),!d){var l=window.navigator.appVersion.match(/Chrome\/(.*?) /);if(l&&parseInt(l[1])>=36)X=!1;else{var m=k.cloneRange();k.setStart(j,0),m.setEnd(j,3),m.setStart(j,2),b.addRange(k),b.addRange(m),X=2==b.rangeCount}}for(C.removeNode(i),b.removeAllRanges(),h=0;c>h;++h)0==h&&f?Z?Z(b,e[h]):(a.warn("Rangy initialization: original selection was backwards but selection has been restored forwards because the browser does not support Selection.extend"),b.addRange(e[h])):b.addRange(e[h])}}(),J.selectionSupportsMultipleRanges=X,J.collapsedNonEditableSelectionsSupported=Y;var $,_=!1;T&&E(T,"createControlRange")&&($=T.createControlRange(),D.areHostProperties($,["item","add"])&&(_=!0)),J.implementsControlRange=_,z=U?function(a){return a.anchorNode===a.focusNode&&a.anchorOffset===a.focusOffset}:function(a){return a.rangeCount?a.getRangeAt(a.rangeCount-1).collapsed:!1};var aa;E(R,"getRangeAt")?aa=function(a,b){try{return a.getRangeAt(b)}catch(c){return null}}:U&&(aa=function(b){var c=L(b.anchorNode),d=a.createRange(c);return d.setStartAndEnd(b.anchorNode,b.anchorOffset,b.focusNode,b.focusOffset),d.collapsed!==this.isCollapsed&&d.setStartAndEnd(b.focusNode,b.focusOffset,b.anchorNode,b.anchorOffset),d}),r.prototype=a.selectionPrototype;var ba=[],ca=function(a){if(a&&a instanceof r)return a.refresh(),a;a=d(a,"getNativeSelection");var b=t(a),c=y(a),e=P?f(a):null;return b?(b.nativeSelection=c,b.docSelection=e,b.refresh()):(b=new r(c,e,a),ba.push({win:a,selection:b})),b};a.getSelection=ca,D.createAliasForDeprecatedMethod(a,"getIframeSelection","getSelection");var da=r.prototype;if(!Q&&U&&D.areHostMethods(R,["removeAllRanges","addRange"])){da.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),j(this)};var ea=function(a,b){Z(a.nativeSelection,b),a.refresh()};W?da.addRange=function(b,d){if(_&&P&&this.docSelection.type==K)q(this,b);else if(c(d)&&V)ea(this,b);else{var e;X?e=this.rangeCount:(this.removeAllRanges(),e=0);var f=k(b).cloneRange();try{this.nativeSelection.addRange(f)}catch(g){}if(this.rangeCount=this.nativeSelection.rangeCount,this.rangeCount==e+1){if(a.config.checkSelectionRanges){var i=aa(this.nativeSelection,this.rangeCount-1);i&&!N(i,b)&&(b=new G(i))}this._ranges[this.rangeCount-1]=b,h(this,b,ha(this.nativeSelection)),this.isCollapsed=z(this)}else this.refresh()}}:da.addRange=function(a,b){c(b)&&V?ea(this,a):(this.nativeSelection.addRange(k(a)),this.refresh())},da.setRanges=function(a){if(_&&P&&a.length>1)u(this,a);else{this.removeAllRanges();for(var b=0,c=a.length;c>b;++b)this.addRange(a[b])}}}else{if(!(E(R,"empty")&&E(S,"select")&&_&&Q))return b.fail("No means of selecting a Range or TextRange was found"),!1;da.removeAllRanges=function(){try{if(this.docSelection.empty(),"None"!=this.docSelection.type){var a;if(this.anchorNode)a=L(this.anchorNode);else if(this.docSelection.type==K){var b=this.docSelection.createRange();b.length&&(a=L(b.item(0)))}if(a){var c=M(a).createTextRange();c.select(),this.docSelection.empty()}}}catch(d){}j(this)},da.addRange=function(b){this.docSelection.type==K?q(this,b):(a.WrappedTextRange.rangeToTextRange(b).select(),this._ranges[0]=b,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,h(this,b,!1))},da.setRanges=function(a){this.removeAllRanges();var b=a.length;b>1?u(this,a):b&&this.addRange(a[0])}}da.getRangeAt=function(a){if(0>a||a>=this.rangeCount)throw new H("INDEX_SIZE_ERR");return this._ranges[a].cloneRange()};var fa;if(Q)fa=function(b){var c;a.isSelectionValid(b.win)?c=b.docSelection.createRange():(c=M(b.win.document).createTextRange(),c.collapse(!0)),b.docSelection.type==K?p(b):n(c)?o(b,c):j(b)};else if(E(R,"getRangeAt")&&typeof R.rangeCount==B)fa=function(b){if(_&&P&&b.docSelection.type==K)p(b);else if(b._ranges.length=b.rangeCount=b.nativeSelection.rangeCount,b.rangeCount){for(var c=0,d=b.rangeCount;d>c;++c)b._ranges[c]=new a.WrappedRange(b.nativeSelection.getRangeAt(c));h(b,b._ranges[b.rangeCount-1],ha(b.nativeSelection)),b.isCollapsed=z(b)}else j(b)};else{if(!U||typeof R.isCollapsed!=A||typeof S.collapsed!=A||!J.implementsDomRange)return b.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;fa=function(a){var b,c=a.nativeSelection;c.anchorNode?(b=aa(c,0),a._ranges=[b],a.rangeCount=1,i(a),a.isCollapsed=z(a)):j(a)}}da.refresh=function(a){var b=a?this._ranges.slice(0):null,c=this.anchorNode,d=this.anchorOffset;if(fa(this),a){var e=b.length;if(e!=this._ranges.length)return!0;if(this.anchorNode!=c||this.anchorOffset!=d)return!0;for(;e--;)if(!N(b[e],this._ranges[e]))return!0;return!1}};var ga=function(a,b){var c=a.getAllRanges();a.removeAllRanges();for(var d=0,e=c.length;e>d;++d)N(b,c[d])||a.addRange(c[d]);a.rangeCount||j(a)};_&&P?da.removeRange=function(a){if(this.docSelection.type==K){for(var b,c=this.docSelection.createRange(),d=m(a),e=L(c.item(0)),f=M(e).createControlRange(),g=!1,h=0,i=c.length;i>h;++h)b=c.item(h),b!==d||g?f.add(c.item(h)):g=!0;f.select(),p(this)}else ga(this,a)}:da.removeRange=function(a){ga(this,a)};var ha;!Q&&U&&J.implementsDomRange?(ha=g,da.isBackward=function(){return ha(this)}):ha=da.isBackward=function(){return!1},da.isBackwards=da.isBackward,da.toString=function(){for(var a=[],b=0,c=this.rangeCount;c>b;++b)a[b]=""+this._ranges[b];return a.join("")},da.collapse=function(b,c){v(this,b);var d=a.createRange(b);d.collapseToPoint(b,c),this.setSingleRange(d),this.isCollapsed=!0},da.collapseToStart=function(){if(!this.rangeCount)throw new H("INVALID_STATE_ERR");var a=this._ranges[0];this.collapse(a.startContainer,a.startOffset)},da.collapseToEnd=function(){if(!this.rangeCount)throw new H("INVALID_STATE_ERR");var a=this._ranges[this.rangeCount-1];this.collapse(a.endContainer,a.endOffset)},da.selectAllChildren=function(b){v(this,b);var c=a.createRange(b);c.selectNodeContents(b),this.setSingleRange(c)},da.deleteFromDocument=function(){if(_&&P&&this.docSelection.type==K){for(var a,b=this.docSelection.createRange();b.length;)a=b.item(0),b.remove(a),C.removeNode(a);this.refresh()}else if(this.rangeCount){var c=this.getAllRanges();if(c.length){this.removeAllRanges();for(var d=0,e=c.length;e>d;++d)c[d].deleteContents();this.addRange(c[e-1])}}},da.eachRange=function(a,b){for(var c=0,d=this._ranges.length;d>c;++c)if(a(this.getRangeAt(c)))return b},da.getAllRanges=function(){var a=[];return this.eachRange(function(b){a.push(b)}),a},da.setSingleRange=function(a,b){this.removeAllRanges(),this.addRange(a,b)},da.callMethodOnEachRange=function(a,b){var c=[];return this.eachRange(function(d){c.push(d[a].apply(d,b||[]))}),c},da.setStart=w(!0),da.setEnd=w(!1),a.rangePrototype.select=function(a){ca(this.getDocument()).setSingleRange(this,a)},da.changeEachRange=function(a){var b=[],c=this.isBackward();this.eachRange(function(c){a(c),b.push(c)}),this.removeAllRanges(),c&&1==b.length?this.addRange(b[0],"backward"):this.setRanges(b)},da.containsNode=function(a,b){return this.eachRange(function(c){return c.containsNode(a,b)},!0)||!1},da.getBookmark=function(a){return{backward:this.isBackward(),rangeBookmarks:this.callMethodOnEachRange("getBookmark",[a])}},da.moveToBookmark=function(b){for(var c,d,e=[],f=0;c=b.rangeBookmarks[f++];)d=a.createRange(this.win),d.moveToBookmark(c),e.push(d);b.backward?this.setSingleRange(e[0],"backward"):this.setRanges(e)},da.saveRanges=function(){return{backward:this.isBackward(),ranges:this.callMethodOnEachRange("cloneRange")}},da.restoreRanges=function(a){this.removeAllRanges();for(var b,c=0;b=a.ranges[c];++c)this.addRange(b,a.backward&&0==c)},da.toHtml=function(){var a=[];return this.eachRange(function(b){a.push(F.toHtml(b))}),a.join("")},J.implementsTextRange&&(da.getNativeTextRange=function(){var c;if(c=this.docSelection){var d=c.createRange();if(n(d))return d;throw b.createError("getNativeTextRange: selection is a control selection")}if(this.rangeCount>0)return a.WrappedTextRange.rangeToTextRange(this.getRangeAt(0));throw b.createError("getNativeTextRange: selection contains no range")}),da.getName=function(){return"WrappedSelection"},da.inspect=function(){return x(this)},da.detach=function(){t(this.win,"delete"),s(this)},r.detachAll=function(){t(null,"deleteAll")},r.inspect=x,r.isDirectionBackward=c,a.Selection=r,a.selectionPrototype=da,a.addShimListener(function(a){"undefined"==typeof a.getSelection&&(a.getSelection=function(){return ca(a)}),a=null})});var M=!1,N=function(a){M||(M=!0,!H.initialized&&H.config.autoInitialize&&l())};F&&("complete"==document.readyState?N():(a(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",N,!1),J(window,"load",N))),rangy=H}(),rangy.createModule("SaveRestore",["WrappedRange"],function(a,b){function c(a,b){return(b||document).getElementById(a)}function d(a,b){var c,d="selectionBoundary_"+ +new Date+"_"+(""+Math.random()).slice(2),e=o.getDocument(a.startContainer),f=a.cloneRange();return f.collapse(b),c=e.createElement("span"),c.id=d,c.style.lineHeight="0",c.style.display="none",c.className="rangySelectionBoundary",c.appendChild(e.createTextNode(r)),f.insertNode(c),c}function e(a,d,e,f){var g=c(e,a);g?(d[f?"setStartBefore":"setEndBefore"](g),p(g)):b.warn("Marker element has been removed. Cannot restore selection.")}function f(a,b){return b.compareBoundaryPoints(a.START_TO_START,a)}function g(b,c){var e,f,g=a.DomRange.getRangeDocument(b),h=b.toString(),i=q(c);return b.collapsed?(f=d(b,!1),{document:g,markerId:f.id,collapsed:!0}):(f=d(b,!1),e=d(b,!0),{document:g,startMarkerId:e.id,endMarkerId:f.id,collapsed:!1,backward:i,toString:function(){return"original text: '"+h+"', new text: '"+b.toString()+"'"}})}function h(d,f){var g=d.document;"undefined"==typeof f&&(f=!0);var h=a.createRange(g);if(d.collapsed){var i=c(d.markerId,g);if(i){i.style.display="inline";var j=i.previousSibling;j&&3==j.nodeType?(p(i),h.collapseToPoint(j,j.length)):(h.collapseBefore(i),p(i))}else b.warn("Marker element has been removed. Cannot restore selection.")}else e(g,h,d.startMarkerId,!0),e(g,h,d.endMarkerId,!1);return f&&h.normalizeBoundaries(),h}function i(b,d){var e,h,i=[],j=q(d);b=b.slice(0),b.sort(f);for(var k=0,l=b.length;l>k;++k)i[k]=g(b[k],j);for(k=l-1;k>=0;--k)e=b[k],h=a.DomRange.getRangeDocument(e),e.collapsed?e.collapseAfter(c(i[k].markerId,h)):(e.setEndBefore(c(i[k].endMarkerId,h)),e.setStartAfter(c(i[k].startMarkerId,h)));return i}function j(c){if(!a.isSelectionValid(c))return b.warn("Cannot save selection. This usually happens when the selection is collapsed and the selection document has lost focus."),null;var d=a.getSelection(c),e=d.getAllRanges(),f=1==e.length&&d.isBackward(),g=i(e,f);return f?d.setSingleRange(e[0],f):d.setRanges(e),{win:c,rangeInfos:g,restored:!1}}function k(a){for(var b=[],c=a.length,d=c-1;d>=0;d--)b[d]=h(a[d],!0);return b}function l(b,c){if(!b.restored){var d=b.rangeInfos,e=a.getSelection(b.win),f=k(d),g=d.length;1==g&&c&&a.features.selectionHasExtend&&d[0].backward?(e.removeAllRanges(),e.addRange(f[0],!0)):e.setRanges(f),b.restored=!0}}function m(a,b){var d=c(b,a);d&&p(d)}function n(a){for(var b,c=a.rangeInfos,d=0,e=c.length;e>d;++d)b=c[d],b.collapsed?m(a.doc,b.markerId):(m(a.doc,b.startMarkerId),m(a.doc,b.endMarkerId))}var o=a.dom,p=o.removeNode,q=a.Selection.isDirectionBackward,r="\ufeff";a.util.extend(a,{saveRange:g,restoreRange:h,saveRanges:i,restoreRanges:k,saveSelection:j,restoreSelection:l,removeMarkerElement:m,removeMarkers:n})}),rangy.createModule("TextRange",["WrappedSelection"],function(a,b){function c(a,b){function c(a,b,c){h.push({start:a,end:b,isWord:c})}for(var d,e,f,g=a.join(""),h=[],i=0;d=b.wordRegex.exec(g);){if(e=d.index,f=e+d[0].length,e>i&&c(i,e,!1),b.includeTrailingSpace)for(;$.test(a[f]);)++f;c(e,f,!0),i=f}return i<a.length&&c(i,a.length,!1),h}function d(a,b){for(var c=a.slice(b.start,b.end),d={isWord:b.isWord,chars:c,toString:function(){return c.join("")}},e=0,f=c.length;f>e;++e)c[e].token=d;return d}function e(a,b,c){for(var e,f=c(a,b),g=[],h=0;e=f[h++];)g.push(d(a,e));return g}function f(a){var b=a||"",c="string"==typeof b?b.split(""):b;return c.sort(function(a,b){return a.charCodeAt(0)-b.charCodeAt(0)}),c.join("").replace(/(.)\1+/g,"$1")}function g(a){var b,c;return a?(b=a.language||_,c={},U(c,ia[b]||ia[_]),U(c,a),c):ia[_]}function h(a,b){var c=V(a,b);return b.hasOwnProperty("wordOptions")&&(c.wordOptions=g(c.wordOptions)),b.hasOwnProperty("characterOptions")&&(c.characterOptions=V(c.characterOptions,ga)),c}function i(a,b){var c=na(a,"display",b),d=a.tagName.toLowerCase();return"block"==c&&fa&&oa.hasOwnProperty(d)?oa[d]:c}function j(a){for(var b=o(a),c=0,d=b.length;d>c;++c)if(1==b[c].nodeType&&"none"==i(b[c]))return!0;return!1}function k(a){var b;return 3==a.nodeType&&(b=a.parentNode)&&"hidden"==na(b,"visibility")}function l(a){return a&&(1==a.nodeType&&!/^(inline(-block|-table)?|none)$/.test(i(a))||9==a.nodeType||11==a.nodeType)}function m(a){return S.isCharacterDataNode(a)||!/^(area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param)$/i.test(a.nodeName)}function n(a){for(var b=[];a.parentNode;)b.unshift(a.parentNode),a=a.parentNode;return b}function o(a){return n(a).concat([a])}function p(a){for(;a&&!a.nextSibling;)a=a.parentNode;return a?a.nextSibling:null}function q(a,b){return!b&&a.hasChildNodes()?a.firstChild:p(a)}function r(a){var b=a.previousSibling;if(b){for(a=b;a.hasChildNodes();)a=a.lastChild;return a}var c=a.parentNode;return c&&1==c.nodeType?c:null}function s(a){if(!a||3!=a.nodeType)return!1;var b=a.data;if(""===b)return!0;var c=a.parentNode;if(!c||1!=c.nodeType)return!1;var d=na(a.parentNode,"whiteSpace");return/^[\t\n\r ]+$/.test(b)&&/^(normal|nowrap)$/.test(d)||/^[\t\r ]+$/.test(b)&&"pre-line"==d}function t(a){if(""===a.data)return!0;if(!s(a))return!1;var b=a.parentNode;return b?j(a)?!0:!1:!0}function u(a){var b=a.nodeType;return 7==b||8==b||j(a)||/^(script|style)$/i.test(a.nodeName)||k(a)||t(a)}function v(a,b){var c=a.nodeType;return 7==c||8==c||1==c&&"none"==i(a,b)}function w(){this.store={}}function x(a,b,c){return function(d){var e=this.cache;if(e.hasOwnProperty(a))return pa++,e[a];qa++;var f=b.call(this,c?this[c]:this,d);return e[a]=f,f}}function y(a,b){this.node=a,this.session=b,this.cache=new w,this.positions=new w}function z(a,b){this.offset=b,this.nodeWrapper=a,this.node=a.node,this.session=a.session,this.cache=new w}function A(){return"[Position("+S.inspectNode(this.node)+":"+this.offset+")]"}function B(){return D(),Da=new Ea}function C(){return Da||B()}function D(){Da&&Da.detach(),Da=null}function E(a,c,d,e){function f(){var a=null;return c?(a=h,i||(h=h.previousVisible(),i=!h||d&&h.equals(d))):i||(a=h=h.nextVisible(),i=!h||d&&h.equals(d)),i&&(h=null),a}d&&(c?u(d.node)&&(d=a.previousVisible()):u(d.node)&&(d=d.nextVisible()));var g,h=a,i=!1,j=!1;return{next:function(){if(j)return j=!1,g;for(var a,b;a=f();)if(b=a.getCharacter(e))return g=a,a;return null},rewind:function(){if(!g)throw b.createError("createCharacterIterator: cannot rewind. Only one position can be rewound.");j=!0},dispose:function(){a=d=null}}}function F(a,b,c){function d(a){for(var b,c,d=[],e=a?f:g,h=!1,i=!1;b=e.next();){if(c=b.character,Z.test(c))i&&(i=!1,h=!0);else{if(h){e.rewind();break}i=!0}d.push(b)}return d}var f=E(a,!1,null,b),g=E(a,!0,null,b),h=c.tokenizer,i=d(!0),j=d(!1).reverse(),k=e(j.concat(i),c,h),l=i.length?k.slice(Fa(k,i[0].token)):[],m=j.length?k.slice(0,Fa(k,j.pop().token)+1):[];return{nextEndToken:function(){for(var a,b;1==l.length&&!(a=l[0]).isWord&&(b=d(!0)).length>0;)l=e(a.chars.concat(b),c,h);return l.shift()},previousStartToken:function(){for(var a,b;1==m.length&&!(a=m[0]).isWord&&(b=d(!1)).length>0;)m=e(b.reverse().concat(a.chars),c,h);return m.pop()},dispose:function(){f.dispose(),g.dispose(),l=m=null}}}function G(a,b,c,d,e){var f,g,h,i,j=0,k=a,l=Math.abs(c);if(0!==c){var m=0>c;switch(b){case Q:for(g=E(a,m,null,d);(f=g.next())&&l>j;)++j,k=f;h=f,g.dispose();break;case R:for(var n=F(a,d,e),o=m?n.previousStartToken:n.nextEndToken;(i=o())&&l>j;)i.isWord&&(++j,k=m?i.chars[0]:i.chars[i.chars.length-1]);break;default:throw new Error("movePositionBy: unit '"+b+"' not implemented")}m?(k=k.previousVisible(),j=-j):k&&k.isLeadingSpace&&!k.isTrailingSpace&&(b==R&&(g=E(a,!1,null,d),h=g.next(),g.dispose()),h&&(k=h.previousVisible()))}return{position:k,unitsMoved:j}}function H(a,b,c,d){var e=a.getRangeBoundaryPosition(b,!0),f=a.getRangeBoundaryPosition(b,!1),g=d?f:e,h=d?e:f;return E(g,!!d,h,c)}function I(a,b,c){for(var d,e=[],f=H(a,b,c);d=f.next();)e.push(d);return f.dispose(),e}function J(b,c,d){var e=a.createRange(b.node);return e.setStartAndEnd(b.node,b.offset,c.node,c.offset),!e.expand("word",{wordOptions:d})}function K(a,b,c,d,e){function f(a,b){var c=p[a].previousVisible(),d=p[b-1],f=!e.wholeWordsOnly||J(c,d,e.wordOptions);return{startPos:c,endPos:d,valid:f}}for(var g,h,i,j,k,l,m=aa(e.direction),n=E(a,m,a.session.getRangeBoundaryPosition(d,m),e.characterOptions),o="",p=[],q=null;g=n.next();)if(h=g.character,c||e.caseSensitive||(h=h.toLowerCase()),m?(p.unshift(g),o=h+o):(p.push(g),o+=h),c){if(k=b.exec(o))if(i=k.index,j=i+k[0].length,l){if(!m&&j<o.length||m&&i>0){q=f(i,j);break}}else l=!0}else if(-1!=(i=o.indexOf(b))){q=f(i,i+b.length);break}return l&&(q=f(i,j)),n.dispose(),q}function L(a){return function(){var b=!!Da,c=C(),d=[c].concat(T.toArray(arguments)),e=a.apply(this,d);return b||D(),e}}function M(a,b){return L(function(c,d,e,f){typeof e==P&&(e=d,d=Q),f=h(f,ka);var g=a;b&&(g=e>=0,this.collapse(!g));var i=G(c.getRangeBoundaryPosition(this,g),d,e,f.characterOptions,f.wordOptions),j=i.position;return this[g?"setStart":"setEnd"](j.node,j.offset),i.unitsMoved})}function N(a){return L(function(b,c){c=V(c,ga);for(var d,e=H(b,this,c,!a),f=0;(d=e.next())&&Z.test(d.character);)++f;e.dispose();var g=f>0;return g&&this[a?"moveStart":"moveEnd"]("character",a?f:-f,{characterOptions:c}),g})}function O(a){return L(function(b,c){var d=!1;return this.changeEachRange(function(b){d=b[a](c)||d}),d})}var P="undefined",Q="character",R="word",S=a.dom,T=a.util,U=T.extend,V=T.createOptions,W=S.getBody,X=/^[ \t\f\r\n]+$/,Y=/^[ \t\f\r]+$/,Z=/^[\t-\r \u0085\u00A0\u1680\u180E\u2000-\u200B\u2028\u2029\u202F\u205F\u3000]+$/,$=/^[\t \u00A0\u1680\u180E\u2000-\u200B\u202F\u205F\u3000]+$/,_="en",aa=a.Selection.isDirectionBackward,ba=!1,ca=!1,da=!1,ea=!0;!function(){var b=S.createTestElement(document,"<p>1 </p><p></p>",!0),c=b.firstChild,d=a.getSelection();d.collapse(c.lastChild,2),d.setStart(c.firstChild,0),ba=1==(""+d).length,b.innerHTML="1 <br />",d.collapse(b,2),
  d.setStart(b.firstChild,0),ca=1==(""+d).length,b.innerHTML="1 <p>1</p>",d.collapse(b,2),d.setStart(b.firstChild,0),da=1==(""+d).length,S.removeNode(b),d.removeAllRanges()}();var fa,ga={includeBlockContentTrailingSpace:!0,includeSpaceBeforeBr:!0,includeSpaceBeforeBlock:!0,includePreLineTrailingSpace:!0,ignoreCharacters:""},ha={includeBlockContentTrailingSpace:!ea,includeSpaceBeforeBr:!ca,includeSpaceBeforeBlock:!da,includePreLineTrailingSpace:!0},ia={en:{wordRegex:/[a-z0-9]+('[a-z0-9]+)*/gi,includeTrailingSpace:!1,tokenizer:c}},ja={caseSensitive:!1,withinRange:null,wholeWordsOnly:!1,wrap:!1,direction:"forward",wordOptions:null,characterOptions:null},ka={wordOptions:null,characterOptions:null},la={wordOptions:null,characterOptions:null,trim:!1,trimStart:!0,trimEnd:!0},ma={wordOptions:null,characterOptions:null,direction:"forward"},na=S.getComputedStyleProperty;!function(){var a=document.createElement("table"),b=W(document);b.appendChild(a),fa="block"==na(a,"display"),b.removeChild(a)}();var oa={table:"table",caption:"table-caption",colgroup:"table-column-group",col:"table-column",thead:"table-header-group",tbody:"table-row-group",tfoot:"table-footer-group",tr:"table-row",td:"table-cell",th:"table-cell"};w.prototype={get:function(a){return this.store.hasOwnProperty(a)?this.store[a]:null},set:function(a,b){return this.store[a]=b}};var pa=0,qa=0,ra={getPosition:function(a){var b=this.positions;return b.get(a)||b.set(a,new z(this,a))},toString:function(){return"[NodeWrapper("+S.inspectNode(this.node)+")]"}};y.prototype=ra;var sa="EMPTY",ta="NON_SPACE",ua="UNCOLLAPSIBLE_SPACE",va="COLLAPSIBLE_SPACE",wa="TRAILING_SPACE_BEFORE_BLOCK",xa="TRAILING_SPACE_IN_BLOCK",ya="TRAILING_SPACE_BEFORE_BR",za="PRE_LINE_TRAILING_SPACE_BEFORE_LINE_BREAK",Aa="TRAILING_LINE_BREAK_AFTER_BR",Ba="INCLUDED_TRAILING_LINE_BREAK_AFTER_BR";U(ra,{isCharacterDataNode:x("isCharacterDataNode",S.isCharacterDataNode,"node"),getNodeIndex:x("nodeIndex",S.getNodeIndex,"node"),getLength:x("nodeLength",S.getNodeLength,"node"),containsPositions:x("containsPositions",m,"node"),isWhitespace:x("isWhitespace",s,"node"),isCollapsedWhitespace:x("isCollapsedWhitespace",t,"node"),getComputedDisplay:x("computedDisplay",i,"node"),isCollapsed:x("collapsed",u,"node"),isIgnored:x("ignored",v,"node"),next:x("nextPos",q,"node"),previous:x("previous",r,"node"),getTextNodeInfo:x("textNodeInfo",function(a){var b=null,c=!1,d=na(a.parentNode,"whiteSpace"),e="pre-line"==d;return e?(b=Y,c=!0):("normal"==d||"nowrap"==d)&&(b=X,c=!0),{node:a,text:a.data,spaceRegex:b,collapseSpaces:c,preLine:e}},"node"),hasInnerText:x("hasInnerText",function(a,b){for(var c=this.session,d=c.getPosition(a.parentNode,this.getNodeIndex()+1),e=c.getPosition(a,0),f=b?d:e,g=b?e:d;f!==g;){if(f.prepopulateChar(),f.isDefinitelyNonEmpty())return!0;f=b?f.previousVisible():f.nextVisible()}return!1},"node"),isRenderedBlock:x("isRenderedBlock",function(a){for(var b=a.getElementsByTagName("br"),c=0,d=b.length;d>c;++c)if(!u(b[c]))return!0;return this.hasInnerText()},"node"),getTrailingSpace:x("trailingSpace",function(a){if("br"==a.tagName.toLowerCase())return"";switch(this.getComputedDisplay()){case"inline":for(var b=a.lastChild;b;){if(!v(b))return 1==b.nodeType?this.session.getNodeWrapper(b).getTrailingSpace():"";b=b.previousSibling}break;case"inline-block":case"inline-table":case"none":case"table-column":case"table-column-group":break;case"table-cell":return"	";default:return this.isRenderedBlock(!0)?"\n":""}return""},"node"),getLeadingSpace:x("leadingSpace",function(a){switch(this.getComputedDisplay()){case"inline":case"inline-block":case"inline-table":case"none":case"table-column":case"table-column-group":case"table-cell":break;default:return this.isRenderedBlock(!1)?"\n":""}return""},"node")});var Ca={character:"",characterType:sa,isBr:!1,prepopulateChar:function(){var a=this;if(!a.prepopulatedChar){var b=a.node,c=a.offset,d="",e=sa,f=!1;if(c>0)if(3==b.nodeType){var g=b.data,h=g.charAt(c-1),i=a.nodeWrapper.getTextNodeInfo(),j=i.spaceRegex;i.collapseSpaces?j.test(h)?c>1&&j.test(g.charAt(c-2))||(i.preLine&&"\n"===g.charAt(c)?(d=" ",e=za):(d=" ",e=va)):(d=h,e=ta,f=!0):(d=h,e=ua,f=!0)}else{var k=b.childNodes[c-1];if(k&&1==k.nodeType&&!u(k)&&("br"==k.tagName.toLowerCase()?(d="\n",a.isBr=!0,e=va,f=!1):a.checkForTrailingSpace=!0),!d){var l=b.childNodes[c];l&&1==l.nodeType&&!u(l)&&(a.checkForLeadingSpace=!0)}}a.prepopulatedChar=!0,a.character=d,a.characterType=e,a.isCharInvariant=f}},isDefinitelyNonEmpty:function(){var a=this.characterType;return a==ta||a==ua},resolveLeadingAndTrailingSpaces:function(){if(this.prepopulatedChar||this.prepopulateChar(),this.checkForTrailingSpace){var a=this.session.getNodeWrapper(this.node.childNodes[this.offset-1]).getTrailingSpace();a&&(this.isTrailingSpace=!0,this.character=a,this.characterType=va),this.checkForTrailingSpace=!1}if(this.checkForLeadingSpace){var b=this.session.getNodeWrapper(this.node.childNodes[this.offset]).getLeadingSpace();b&&(this.isLeadingSpace=!0,this.character=b,this.characterType=va),this.checkForLeadingSpace=!1}},getPrecedingUncollapsedPosition:function(a){for(var b,c=this;c=c.previousVisible();)if(b=c.getCharacter(a),""!==b)return c;return null},getCharacter:function(a){function b(){return n||(k=o.getPrecedingUncollapsedPosition(a),n=!0),k}this.resolveLeadingAndTrailingSpaces();var c,d=this.character,e=f(a.ignoreCharacters),g=""!==d&&e.indexOf(d)>-1;if(this.isCharInvariant)return c=g?"":d;var h=["character",a.includeSpaceBeforeBr,a.includeBlockContentTrailingSpace,a.includePreLineTrailingSpace,e].join("_"),i=this.cache.get(h);if(null!==i)return i;var j,k,l="",m=this.characterType==va,n=!1,o=this;return m&&(this.type==Ba?l="\n":" "==d&&(!b()||k.isTrailingSpace||"\n"==k.character||" "==k.character&&k.characterType==va)||("\n"==d&&this.isLeadingSpace?b()&&"\n"!=k.character&&(l="\n"):(j=this.nextUncollapsed(),j&&(j.isBr?this.type=ya:j.isTrailingSpace&&"\n"==j.character?this.type=xa:j.isLeadingSpace&&"\n"==j.character&&(this.type=wa),"\n"==j.character?(this.type!=ya||a.includeSpaceBeforeBr)&&(this.type!=wa||a.includeSpaceBeforeBlock)&&(this.type==xa&&j.isTrailingSpace&&!a.includeBlockContentTrailingSpace||(this.type!=za||j.type!=ta||a.includePreLineTrailingSpace)&&("\n"==d?j.isTrailingSpace?this.isTrailingSpace||this.isBr&&(j.type=Aa,b()&&k.isLeadingSpace&&!k.isTrailingSpace&&"\n"==k.character?j.character="":j.type=Ba):l="\n":" "==d&&(l=" "))):l=d)))),e.indexOf(l)>-1&&(l=""),this.cache.set(h,l),l},equals:function(a){return!!a&&this.node===a.node&&this.offset===a.offset},inspect:A,toString:function(){return this.character}};z.prototype=Ca,U(Ca,{next:x("nextPos",function(a){var b=a.nodeWrapper,c=a.node,d=a.offset,e=b.session;if(!c)return null;var f,g,h;return d==b.getLength()?(f=c.parentNode,g=f?b.getNodeIndex()+1:0):b.isCharacterDataNode()?(f=c,g=d+1):(h=c.childNodes[d],e.getNodeWrapper(h).containsPositions()?(f=h,g=0):(f=c,g=d+1)),f?e.getPosition(f,g):null}),previous:x("previous",function(a){var b,c,d,e=a.nodeWrapper,f=a.node,g=a.offset,h=e.session;return 0==g?(b=f.parentNode,c=b?e.getNodeIndex():0):e.isCharacterDataNode()?(b=f,c=g-1):(d=f.childNodes[g-1],h.getNodeWrapper(d).containsPositions()?(b=d,c=S.getNodeLength(d)):(b=f,c=g-1)),b?h.getPosition(b,c):null}),nextVisible:x("nextVisible",function(a){var b=a.next();if(!b)return null;var c=b.nodeWrapper,d=b.node,e=b;return c.isCollapsed()&&(e=c.session.getPosition(d.parentNode,c.getNodeIndex()+1)),e}),nextUncollapsed:x("nextUncollapsed",function(a){for(var b=a;b=b.nextVisible();)if(b.resolveLeadingAndTrailingSpaces(),""!==b.character)return b;return null}),previousVisible:x("previousVisible",function(a){var b=a.previous();if(!b)return null;var c=b.nodeWrapper,d=b.node,e=b;return c.isCollapsed()&&(e=c.session.getPosition(d.parentNode,c.getNodeIndex())),e})});var Da=null,Ea=function(){function a(a){var b=new w;return{get:function(c){var d=b.get(c[a]);if(d)for(var e,f=0;e=d[f++];)if(e.node===c)return e;return null},set:function(c){var d=c.node[a],e=b.get(d)||b.set(d,[]);e.push(c)}}}function b(){this.initCaches()}var c=T.isHostProperty(document.documentElement,"uniqueID");return b.prototype={initCaches:function(){this.elementCache=c?function(){var a=new w;return{get:function(b){return a.get(b.uniqueID)},set:function(b){a.set(b.node.uniqueID,b)}}}():a("tagName"),this.textNodeCache=a("data"),this.otherNodeCache=a("nodeName")},getNodeWrapper:function(a){var b;switch(a.nodeType){case 1:b=this.elementCache;break;case 3:b=this.textNodeCache;break;default:b=this.otherNodeCache}var c=b.get(a);return c||(c=new y(a,this),b.set(c)),c},getPosition:function(a,b){return this.getNodeWrapper(a).getPosition(b)},getRangeBoundaryPosition:function(a,b){var c=b?"start":"end";return this.getPosition(a[c+"Container"],a[c+"Offset"])},detach:function(){this.elementCache=this.textNodeCache=this.otherNodeCache=null}},b}();U(S,{nextNode:q,previousNode:r});var Fa=Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){for(var c=0,d=a.length;d>c;++c)if(a[c]===b)return c;return-1};U(a.rangePrototype,{moveStart:M(!0,!1),moveEnd:M(!1,!1),move:M(!0,!0),trimStart:N(!0),trimEnd:N(!1),trim:L(function(a,b){var c=this.trimStart(b),d=this.trimEnd(b);return c||d}),expand:L(function(a,b,c){var d=!1;c=h(c,la);var e=c.characterOptions;if(b||(b=Q),b==R){var f,g,i=c.wordOptions,j=a.getRangeBoundaryPosition(this,!0),k=a.getRangeBoundaryPosition(this,!1),l=F(j,e,i),m=l.nextEndToken(),n=m.chars[0].previousVisible();if(this.collapsed)f=m;else{var o=F(k,e,i);f=o.previousStartToken()}return g=f.chars[f.chars.length-1],n.equals(j)||(this.setStart(n.node,n.offset),d=!0),g&&!g.equals(k)&&(this.setEnd(g.node,g.offset),d=!0),c.trim&&(c.trimStart&&(d=this.trimStart(e)||d),c.trimEnd&&(d=this.trimEnd(e)||d)),d}return this.moveEnd(Q,1,c)}),text:L(function(a,b){return this.collapsed?"":I(a,this,V(b,ga)).join("")}),selectCharacters:L(function(a,b,c,d,e){var f={characterOptions:e};b||(b=W(this.getDocument())),this.selectNodeContents(b),this.collapse(!0),this.moveStart("character",c,f),this.collapse(!0),this.moveEnd("character",d-c,f)}),toCharacterRange:L(function(a,b,c){b||(b=W(this.getDocument()));var d,e,f=b.parentNode,g=S.getNodeIndex(b),h=-1==S.comparePoints(this.startContainer,this.endContainer,f,g),i=this.cloneRange();return h?(i.setStartAndEnd(this.startContainer,this.startOffset,f,g),d=-i.text(c).length):(i.setStartAndEnd(f,g,this.startContainer,this.startOffset),d=i.text(c).length),e=d+this.text(c).length,{start:d,end:e}}),findText:L(function(b,c,d){d=h(d,ja),d.wholeWordsOnly&&(d.wordOptions.includeTrailingSpace=!1);var e=aa(d.direction),f=d.withinRange;f||(f=a.createRange(),f.selectNodeContents(this.getDocument()));var g=c,i=!1;"string"==typeof g?d.caseSensitive||(g=g.toLowerCase()):i=!0;var j=b.getRangeBoundaryPosition(this,!e),k=f.comparePoint(j.node,j.offset);-1===k?j=b.getRangeBoundaryPosition(f,!0):1===k&&(j=b.getRangeBoundaryPosition(f,!1));for(var l,m=j,n=!1;;)if(l=K(m,g,i,f,d)){if(l.valid)return this.setStartAndEnd(l.startPos.node,l.startPos.offset,l.endPos.node,l.endPos.offset),!0;m=e?l.startPos:l.endPos}else{if(!d.wrap||n)return!1;f=f.cloneRange(),m=b.getRangeBoundaryPosition(f,!e),f.setBoundary(j.node,j.offset,e),n=!0}}),pasteHtml:function(a){if(this.deleteContents(),a){var b=this.createContextualFragment(a),c=b.lastChild;this.insertNode(b),this.collapseAfter(c)}}}),U(a.selectionPrototype,{expand:L(function(a,b,c){this.changeEachRange(function(a){a.expand(b,c)})}),move:L(function(a,b,c,d){var e=0;if(this.focusNode){this.collapse(this.focusNode,this.focusOffset);var f=this.getRangeAt(0);d||(d={}),d.characterOptions=V(d.characterOptions,ha),e=f.move(b,c,d),this.setSingleRange(f)}return e}),trimStart:O("trimStart"),trimEnd:O("trimEnd"),trim:O("trim"),selectCharacters:L(function(b,c,d,e,f,g){var h=a.createRange(c);h.selectCharacters(c,d,e,g),this.setSingleRange(h,f)}),saveCharacterRanges:L(function(a,b,c){for(var d=this.getAllRanges(),e=d.length,f=[],g=1==e&&this.isBackward(),h=0,i=d.length;i>h;++h)f[h]={characterRange:d[h].toCharacterRange(b,c),backward:g,characterOptions:c};return f}),restoreCharacterRanges:L(function(b,c,d){this.removeAllRanges();for(var e,f,g,h=0,i=d.length;i>h;++h)f=d[h],g=f.characterRange,e=a.createRange(c),e.selectCharacters(c,g.start,g.end,f.characterOptions),this.addRange(e,f.backward)}),text:L(function(a,b){for(var c=[],d=0,e=this.rangeCount;e>d;++d)c[d]=this.getRangeAt(d).text(b);return c.join("")})}),a.innerText=function(b,c){var d=a.createRange(b);d.selectNodeContents(b);var e=d.text(c);return e},a.createWordIterator=function(a,b,c){var d=C();c=h(c,ma);var e=d.getPosition(a,b),f=F(e,c.characterOptions,c.wordOptions),g=aa(c.direction);return{next:function(){return g?f.previousStartToken():f.nextEndToken()},dispose:function(){f.dispose(),this.next=function(){}}}},a.noMutation=function(a){var b=C();a(b),D()},a.noMutation.createEntryPointFunction=L,a.textRange={isBlockNode:l,isCollapsedWhitespaceNode:t,createPosition:L(function(a,b,c){return a.getPosition(b,c)})}}),wysihtml.browser=function(){function a(a){return+(/ipad|iphone|ipod/.test(a)&&a.match(/ os (\d+).+? like mac os x/)||[void 0,0])[1]}function b(a){return+(a.match(/android (\d+)/)||[void 0,0])[1]}function c(a,b){var c,d=-1;return"Microsoft Internet Explorer"==navigator.appName?c=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"):"Netscape"==navigator.appName&&(navigator.userAgent.indexOf("Trident")>-1?c=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"):/Edge\/(\d+)./i.test(navigator.userAgent)&&(c=/Edge\/(\d+)./i)),c&&null!=c.exec(navigator.userAgent)&&(d=parseFloat(RegExp.$1)),-1===d?!1:a?b?"<"===b?d>a:">"===b?a>d:"<="===b?d>=a:">="===b?a>=d:void 0:a===d:!0}var d=navigator.userAgent,e=document.createElement("div"),f=-1!==d.indexOf("Gecko")&&-1===d.indexOf("KHTML")&&!c(),g=-1!==d.indexOf("AppleWebKit/")&&!c(),h=-1!==d.indexOf("Chrome/")&&!c(),i=-1!==d.indexOf("Opera/")&&!c();return{USER_AGENT:d,supported:function(){var c=this.USER_AGENT.toLowerCase(),d="contentEditable"in e,f=document.execCommand&&document.queryCommandSupported&&document.queryCommandState,g=document.querySelector&&document.querySelectorAll,h=this.isIos()&&a(c)<5||this.isAndroid()&&b(c)<4||-1!==c.indexOf("opera mobi")||-1!==c.indexOf("hpwos/");return d&&f&&g&&!h},isTouchDevice:function(){return this.supportsEvent("touchmove")},isIos:function(){return/ipad|iphone|ipod/i.test(this.USER_AGENT)},isAndroid:function(){return-1!==this.USER_AGENT.indexOf("Android")},supportsSandboxedIframes:function(){return c()},throwsMixedContentWarningWhenIframeSrcIsEmpty:function(){return!("querySelector"in document)},displaysCaretInEmptyContentEditableCorrectly:function(){return c(12,">")},hasCurrentStyleProperty:function(){return"currentStyle"in e},insertsLineBreaksOnReturn:function(){return f},supportsPlaceholderAttributeOn:function(a){return"placeholder"in a},supportsEvent:function(a){return"on"+a in e||function(){return e.setAttribute("on"+a,"return;"),"function"==typeof e["on"+a]}()},supportsEventsInIframeCorrectly:function(){return!i},supportsHTML5Tags:function(a){var b=a.createElement("div"),c="<article>foo</article>";return b.innerHTML=c,b.innerHTML.toLowerCase()===c},supportsCommand:function(){var a={formatBlock:c(10,"<="),insertUnorderedList:c(),insertOrderedList:c()},b={insertHTML:f};return function(c,d){var e=a[d];if(!e){try{return c.queryCommandSupported(d)}catch(f){}try{return c.queryCommandEnabled(d)}catch(g){return!!b[d]}}return!1}}(),doesAutoLinkingInContentEditable:function(){return c()},canDisableAutoLinking:function(){return this.supportsCommand(document,"AutoUrlDetect")},clearsContentEditableCorrectly:function(){return f||i||g},supportsGetAttributeCorrectly:function(){var a=document.createElement("td");return"1"!=a.getAttribute("rowspan")},canSelectImagesInContentEditable:function(){return f||c()||i},autoScrollsToCaret:function(){return!g},autoClosesUnclosedTags:function(){var a,b,c=e.cloneNode(!1);return c.innerHTML="<p><div></div>",b=c.innerHTML.toLowerCase(),a="<p></p><div></div>"===b||"<p><div></div></p>"===b,this.autoClosesUnclosedTags=function(){return a},a},supportsNativeGetElementsByClassName:function(){return-1!==String(document.getElementsByClassName).indexOf("[native code]")},supportsSelectionModify:function(){return"getSelection"in window&&"modify"in window.getSelection()},needsSpaceAfterLineBreak:function(){return i},supportsSpeechApiOn:function(a){var b=d.match(/Chrome\/(\d+)/)||[void 0,0];return b[1]>=11&&("onwebkitspeechchange"in a||"speech"in a)},crashesWhenDefineProperty:function(a){return c(9)&&("XMLHttpRequest"===a||"XDomainRequest"===a)},doesAsyncFocus:function(){return c(12,">")},hasProblemsSettingCaretAfterImg:function(){return c()},hasLiDeletingProblem:function(){return c()},hasUndoInContextMenu:function(){return f||h||i},hasInsertNodeIssue:function(){return i},hasIframeFocusIssue:function(){return c()},createsNestedInvalidMarkupAfterPaste:function(){return g},hasCaretBlockElementIssue:function(){return g},supportsMutationEvents:function(){return"MutationEvent"in window},supportsModernPaste:function(){return!c()},fixStyleKey:function(a){return"cssFloat"===a?"styleFloat"in document.createElement("div").style?"styleFloat":"cssFloat":a},usesControlRanges:function(){return document.body&&"createControlRange"in document.body},hasCaretAtLinkEndInsertionProblems:function(){return g}}}(),wysihtml.lang.array=function(a){return{contains:function(b){if(Array.isArray(b)){for(var c=b.length;c--;)if(-1!==wysihtml.lang.array(a).indexOf(b[c]))return!0;return!1}return-1!==wysihtml.lang.array(a).indexOf(b)},indexOf:function(b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},without:function(b){b=wysihtml.lang.array(b);for(var c=[],d=0,e=a.length;e>d;d++)b.contains(a[d])||c.push(a[d]);return c},get:function(){for(var b=0,c=a.length,d=[];c>b;b++)d.push(a[b]);return d},map:function(b,c){if(Array.prototype.map)return a.map(b,c);for(var d=a.length>>>0,e=new Array(d),f=0;d>f;f++)e[f]=b.call(c,a[f],f,a);return e},unique:function(){for(var b=[],c=a.length,d=0;c>d;)wysihtml.lang.array(b).contains(a[d])||b.push(a[d]),d++;return b}}},wysihtml.lang.Dispatcher=Base.extend({on:function(a,b){return this.events=this.events||{},this.events[a]=this.events[a]||[],this.events[a].push(b),this},off:function(a,b){this.events=this.events||{};var c,d,e=0;if(a){for(c=this.events[a]||[],d=[];e<c.length;e++)c[e]!==b&&b&&d.push(c[e]);this.events[a]=d}else this.events={};return this},fire:function(a,b){this.events=this.events||{};for(var c=this.events[a]||[],d=0;d<c.length;d++)c[d].call(this,b);return this},observe:function(){return this.on.apply(this,arguments)},stopObserving:function(){return this.off.apply(this,arguments)}}),wysihtml.lang.object=function(a){return{merge:function(b,c){for(var d in b)c&&wysihtml.lang.object(b[d]).isPlainObject()&&("undefined"==typeof a[d]||wysihtml.lang.object(a[d]).isPlainObject())?"undefined"==typeof a[d]?a[d]=wysihtml.lang.object(b[d]).clone(!0):wysihtml.lang.object(a[d]).merge(wysihtml.lang.object(b[d]).clone(!0)):a[d]=wysihtml.lang.object(b[d]).isPlainObject()?wysihtml.lang.object(b[d]).clone(!0):b[d];return this},difference:function(b){var c={};for(var d in a)a.hasOwnProperty(d)&&(b.hasOwnProperty(d)||(c[d]=a[d]));for(var e in b)b.hasOwnProperty(e)&&(a.hasOwnProperty(e)&&a[e]===b[e]||(c[0]=a[0]));return c},get:function(){return a},clone:function(b){var c,d={};if(null===a||!wysihtml.lang.object(a).isPlainObject())return a;for(c in a)a.hasOwnProperty(c)&&(b?d[c]=wysihtml.lang.object(a[c]).clone(b):d[c]=a[c]);return d},isArray:function(){return"[object Array]"===Object.prototype.toString.call(a)},isFunction:function(){return"[object Function]"===Object.prototype.toString.call(a)},isPlainObject:function(){return a&&"[object Object]"===Object.prototype.toString.call(a)&&!("Node"in window?a instanceof Node:a instanceof Element||a instanceof Text)},isEmpty:function(){for(var b in a)if(a.hasOwnProperty(b))return!1;return!0}}},function(){var a=/^\s+/,b=/\s+$/,c=/[&<>\t"]/g,d={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","	":"&nbsp; "};wysihtml.lang.string=function(e){return e=String(e),{trim:function(){return e.replace(a,"").replace(b,"")},interpolate:function(a){for(var b in a)e=this.replace("#{"+b+"}").by(a[b]);return e},replace:function(a){return{by:function(b){return e.split(a).join(b)}}},escapeHTML:function(a,b){var f=e.replace(c,function(a){return d[a]});return a&&(f=f.replace(/(?:\r\n|\r|\n)/g,"<br />")),b&&(f=f.replace(/  /gi,"&nbsp; ")),f}}}}(),function(a){function b(a,b){return f(a,b)?a:(a===a.ownerDocument.documentElement&&(a=a.ownerDocument.body),g(a,b))}function c(a){return a.replace(i,function(a,b){var c=(b.match(j)||[])[1]||"",d=l[c];b=b.replace(j,""),b.split(d).length>b.split(c).length&&(b+=c,c="");var e=b,f=b;return b.length>k&&(f=f.substr(0,k)+"..."),"www."===e.substr(0,4)&&(e="http://"+e),'<a href="'+e+'">'+f+"</a>"+c})}function d(a){var b=a._wysihtml_tempElement;return b||(b=a._wysihtml_tempElement=a.createElement("div")),b}function e(b){var e=b.parentNode,f=a.lang.string(b.data).escapeHTML(),g=d(e.ownerDocument);for(g.innerHTML="<span></span>"+c(f),g.removeChild(g.firstChild);g.firstChild;)e.insertBefore(g.firstChild,b);e.removeChild(b)}function f(b,c){for(var d;b.parentNode;){if(b=b.parentNode,d=b.nodeName,b.className&&a.lang.array(b.className.split(" ")).contains(c))return!0;if(h.contains(d))return!0;if("body"===d)return!1}return!1}function g(b,c){if(!(h.contains(b.nodeName)||b.className&&a.lang.array(b.className.split(" ")).contains(c))){if(b.nodeType===a.TEXT_NODE&&b.data.match(i))return void e(b);for(var d=a.lang.array(b.childNodes).get(),f=d.length,j=0;f>j;j++)g(d[j],c);return b}}var h=a.lang.array(["CODE","PRE","A","SCRIPT","HEAD","TITLE","STYLE"]),i=/((https?:\/\/|www\.)[^\s<]{3,})/gi,j=/([^\w\/\-](,?))$/i,k=100,l={")":"(","]":"[","}":"{"};a.dom.autoLink=b,a.dom.autoLink.URL_REG_EXP=i}(wysihtml),function(a){var b=a.dom;b.addClass=function(a,c){var d=a.classList;return d?d.add(c):void(b.hasClass(a,c)||(a.className+=" "+c))},b.removeClass=function(a,b){var c=a.classList;return c?c.remove(b):void(a.className=a.className.replace(new RegExp("(^|\\s+)"+b+"(\\s+|$)")," "))},b.hasClass=function(a,b){var c=a.classList;if(c)return c.contains(b);var d=a.className;return d.length>0&&(d==b||new RegExp("(^|\\s)"+b+"(\\s|$)").test(d))}}(wysihtml),wysihtml.dom.compareDocumentPosition=function(){var a=document.documentElement;return a.compareDocumentPosition?function(a,b){return a.compareDocumentPosition(b)}:function(a,b){var c,d;if(c=9===a.nodeType?a:a.ownerDocument,d=9===b.nodeType?b:b.ownerDocument,a===b)return 0;if(a===b.ownerDocument)return 20;if(a.ownerDocument===b)return 10;if(c!==d)return 1;if(2===a.nodeType&&a.childNodes&&-1!==wysihtml.lang.array(a.childNodes).indexOf(b))return 20;if(2===b.nodeType&&b.childNodes&&-1!==wysihtml.lang.array(b.childNodes).indexOf(a))return 10;for(var e=a,f=[],g=null;e;){if(e==b)return 10;f.push(e),e=e.parentNode}for(e=b,g=null;e;){if(e==a)return 20;var h=wysihtml.lang.array(f).indexOf(e);if(-1!==h){var i=f[h],j=wysihtml.lang.array(i.childNodes).indexOf(f[h-1]),k=wysihtml.lang.array(i.childNodes).indexOf(g);return j>k?2:4}g=e,e=e.parentNode}return 1}}(),wysihtml.dom.contains=function(){var a=document.documentElement;return a.contains?function(a,b){if(b.nodeType!==wysihtml.ELEMENT_NODE){if(b.parentNode===a)return!0;b=b.parentNode}return a!==b&&a.contains(b)}:a.compareDocumentPosition?function(a,b){return!!(16&a.compareDocumentPosition(b))}:void 0}(),function(a){var b=document;a.dom.ContentEditableArea=Base.extend({getContentEditable:function(){return this.element},getWindow:function(){return this.element.ownerDocument.defaultView||this.element.ownerDocument.parentWindow},getDocument:function(){return this.element.ownerDocument},constructor:function(b,c,d){this.callback=b||a.EMPTY_FUNCTION,this.config=a.lang.object({}).merge(c).get(),this.config.className||(this.config.className="wysihtml-sandbox"),d?this.element=this._bindElement(d):this.element=this._createElement()},destroy:function(){},_createElement:function(){var a=b.createElement("div");return a.className=this.config.className,this._loadElement(a),a},_bindElement:function(a){return a.className=a.className?a.className+" wysihtml-sandbox":"wysihtml-sandbox",this._loadElement(a,!0),a},_loadElement:function(a,b){var c=this;if(!b){var d=this._getHtml();a.innerHTML=d}this.loaded=!0,setTimeout(function(){c.callback(c)},0)},_getHtml:function(a){return""}})}(wysihtml),wysihtml.dom.convertToList=function(){function a(a,b){var c=a.createElement("li");return b.appendChild(c),c}function b(a,b){return a.createElement(b)}function c(c,d,e){if("UL"===c.nodeName||"OL"===c.nodeName||"MENU"===c.nodeName)return c;var f,g,h,i,j,k,l,m,n,o=c.ownerDocument,p=b(o,d),q=c.querySelectorAll("br"),r=q.length;for(n=0;r>n;n++)for(i=q[n];(j=i.parentNode)&&j!==c&&j.lastChild===i;){if("block"===wysihtml.dom.getStyle("display").from(j)){j.removeChild(i);break}wysihtml.dom.insert(i).after(i.parentNode)}for(f=wysihtml.lang.array(c.childNodes).get(),g=f.length,n=0;g>n;n++)m=m||a(o,p),h=f[n],k="block"===wysihtml.dom.getStyle("display").from(h),l="BR"===h.nodeName,!k||e&&wysihtml.dom.hasClass(h,e)?l?m=m.firstChild?null:m:m.appendChild(h):(m=m.firstChild?a(o,p):m,m.appendChild(h),m=null);return 0===f.length&&a(o,p),c.parentNode.replaceChild(p,c),p}return c}(),wysihtml.dom.copyAttributes=function(a){return{from:function(b){return{to:function c(d){for(var e,f=0,g=a.length;g>f;f++)e=a[f],"undefined"!=typeof b[e]&&""!==b[e]&&(d[e]=b[e]);return{andTo:c}}}}}},function(a){var b=["-webkit-box-sizing","-moz-box-sizing","-ms-box-sizing","box-sizing"],c=function(b){return d(b)?parseInt(a.getStyle("width").from(b),10)<b.offsetWidth:!1},d=function(c){for(var d=0,e=b.length;e>d;d++)if("border-box"===a.getStyle(b[d]).from(c))return b[d]};a.copyStyles=function(d){return{from:function(e){c(e)&&(d=wysihtml.lang.array(d).without(b));for(var f,g="",h=d.length,i=0;h>i;i++)f=d[i],g+=f+":"+a.getStyle(f).from(e)+";";return{to:function j(b){return a.setStyles(g).on(b),{andTo:j}}}}}}}(wysihtml.dom),function(a){a.dom.delegate=function(a,b,c,d){var e=function(c){for(var e=c.target,f=3===e.nodeType?e.parentNode:e,g=a.querySelectorAll(b),h=0,i=g.length;i>h;h++)g[h].contains(f)&&d.call(g[h],c)};return a.addEventListener(c,e,!1),{stop:function(){a.removeEventListener(c,e,!1)}}}}(wysihtml),function(a){function b(a,b){for(var c=[a],d=a;b&&d&&d!==b||!b&&d;)c.unshift(d),d=d.parentNode;return c}a.dom.domNode=function(c){var d=[a.ELEMENT_NODE,a.TEXT_NODE];return{is:{emptyTextNode:function(b){var d=b?/^\s*$/g:/^[\r\n]*$/g;return c&&c.nodeType===a.TEXT_NODE&&d.test(c.data)},rangyBookmark:function(){return c&&1===c.nodeType&&c.classList.contains("rangySelectionBoundary")},visible:function(){var b=0!=a.dom.getTextContent(c).replace(/\u00a0/g,"x").trim().length;return b||1===c.nodeType&&c.querySelector("img, br, hr, object, embed, canvas, input, textarea")&&(b=!0),b},lineBreak:function(){return c&&1===c.nodeType&&"BR"===c.nodeName},block:function(){return c&&1===c.nodeType&&"block"===c.ownerDocument.defaultView.getComputedStyle(c).display},voidElement:function(){return a.dom.domNode(c).test({query:a.VOID_ELEMENTS})}},prev:function(b){var e=c.previousSibling,f=b&&b.nodeTypes?b.nodeTypes:d;return e?a.dom.domNode(e).is.rangyBookmark()||!a.lang.array(f).contains(e.nodeType)||b&&b.ignoreBlankTexts&&a.dom.domNode(e).is.emptyTextNode(!0)?a.dom.domNode(e).prev(b):e:null},next:function(b){var e=c.nextSibling,f=b&&b.nodeTypes?b.nodeTypes:d;return e?a.dom.domNode(e).is.rangyBookmark()||!a.lang.array(f).contains(e.nodeType)||b&&b.ignoreBlankTexts&&a.dom.domNode(e).is.emptyTextNode(!0)?a.dom.domNode(e).next(b):e:null},commonAncestor:function(a,d){var e=b(c,d),f=b(a,d);if(e[0]!=f[0])return null;for(var g=0;g<e.length;g++)if(e[g]!=f[g])return e[g-1];return null},lastLeafNode:function(b){var d;if(1!==c.nodeType)return c;if(d=c.lastChild,!d)return c;if(b&&b.leafClasses)for(var e=b.leafClasses.length;e--;)if(a.dom.hasClass(c,b.leafClasses[e]))return c;return a.dom.domNode(d).lastLeafNode(b)},escapeParent:function(b,d){var e,f,g,h=c;if(!a.dom.contains(b,c))throw new Error("Child is not a descendant of node.");do{for(e=h.parentNode,f=e.cloneNode(!1);e.lastChild&&e.lastChild!==h;)f.insertBefore(e.lastChild,f.firstChild);if(e!==b&&(g=e.cloneNode(!1),g.appendChild(h),h=g),e.parentNode.insertBefore(h,e.nextSibling),""!==f.innerHTML)if(/^\s+$/.test(f.innerHTML))for(;f.lastChild;)e.parentNode.insertBefore(f.lastChild,h.nextSibling);else e.parentNode.insertBefore(f,h.nextSibling);if(""===e.innerHTML)e.parentNode.removeChild(e);else if(/^\s+$/.test(e.innerHTML)){for(;e.firstChild;)e.parentNode.insertBefore(e.firstChild,e);e.parentNode.removeChild(e)}}while(e&&e!==b);d&&h&&(h.parentNode.insertBefore(d,h),d.appendChild(h))},transferContentTo:function(b,d){if(1===c.nodeType){if(a.dom.domNode(b).is.voidElement()||3===b.nodeType)for(;c.lastChild;)b.parentNode.insertBefore(c.lastChild,b.nextSibling);else for(;c.firstChild;)b.appendChild(c.firstChild);d&&c.parentNode.removeChild(c)}else(3===c.nodeType||8===c.nodeType)&&(a.dom.domNode(b).is.voidElement()?b.parentNode.insertBefore(c,b.nextSibling):b.appendChild(c))},test:function(b){var d;if(!b)return!1;if(1!==c.nodeType)return!1;if(b.query&&!c.matches(b.query))return!1;if(b.nodeName&&c.nodeName.toLowerCase()!==b.nodeName.toLowerCase())return!1;if(b.className&&!c.classList.contains(b.className))return!1;if(b.classRegExp){var e=(c.className||"").match(b.classRegExp)||[];if(0===e.length)return!1}if(b.styleProperty&&b.styleProperty.length>0)for(var f=!1,g=Array.isArray(b.styleProperty)?b.styleProperty:[b.styleProperty],h=0,i=g.length;i>h;h++){if(d=a.browser.fixStyleKey(g[h]),c.style[d]){if(!b.styleValue){f=!0;break}if(b.styleValue instanceof RegExp){if(c.style[d].trim().match(b.styleValue).length>0){f=!0;break}}else if(Array.isArray(b.styleValue)){if(b.styleValue.indexOf(c.style[d].trim())){f=!0;break}}else if(b.styleValue===c.style[d].trim().replace(/, /g,",")){f=!0;break}}if(!f)return!1}if(b.attribute){var j=a.dom.getAttributes(c),k=[],l=!1;Array.isArray(b.attribute)?k=b.attribute:k[b.attribute]=b.attributeValue;for(var m in k)if(k.hasOwnProperty(m))if("undefined"==typeof k[m]){if("undefined"!=typeof j[m]){l=!0;break}}else if(j[m]===k[m]){l=!0;break}if(!l)return!1}return!0}}}}(wysihtml),wysihtml.dom.getAsDom=function(){var a=function(a,b){var c=b.createElement("div");c.style.display="none",b.body.appendChild(c);try{c.innerHTML=a}catch(d){}return b.body.removeChild(c),c},b=function(a){if(!a._wysihtml_supportsHTML5Tags){for(var b=0,d=c.length;d>b;b++)a.createElement(c[b]);a._wysihtml_supportsHTML5Tags=!0}},c=["abbr","article","aside","audio","bdi","canvas","command","datalist","details","figcaption","figure","footer","header","hgroup","keygen","mark","meter","nav","output","progress","rp","rt","ruby","svg","section","source","summary","time","track","video","wbr"];return function(c,d){d=d||document;var e;return"object"==typeof c&&c.nodeType?(e=d.createElement("div"),e.appendChild(c)):wysihtml.browser.supportsHTML5Tags(d)?(e=d.createElement("div"),e.innerHTML=c):(b(d),e=a(c,d)),e}}(),wysihtml.dom.getAttribute=function(a,b){var c=!wysihtml.browser.supportsGetAttributeCorrectly();b=b.toLowerCase();var d=a.nodeName;if("IMG"==d&&"src"==b&&wysihtml.dom.isLoadedImage(a)===!0)return a.src;if(c&&"outerHTML"in a){var e=a.outerHTML.toLowerCase(),f=-1!=e.indexOf(" "+b+"=");return f?a.getAttribute(b):null}return a.getAttribute(b)},wysihtml.dom.getAttributes=function(a){var b,c=!wysihtml.browser.supportsGetAttributeCorrectly(),d=a.nodeName,e=[];for(b in a.attributes)(a.attributes.hasOwnProperty&&a.attributes.hasOwnProperty(b)||!a.attributes.hasOwnProperty&&Object.prototype.hasOwnProperty.call(a.attributes,b))&&a.attributes[b].specified&&("IMG"==d&&"src"==a.attributes[b].name.toLowerCase()&&wysihtml.dom.isLoadedImage(a)===!0?e.src=a.src:wysihtml.lang.array(["rowspan","colspan"]).contains(a.attributes[b].name.toLowerCase())&&c?1!==a.attributes[b].value&&(e[a.attributes[b].name]=a.attributes[b].value):e[a.attributes[b].name]=a.attributes[b].value);
  return e},wysihtml.dom.getParentElement=function(){return function(a,b,c,d){for(c=c||50;c--&&a&&"BODY"!==a.nodeName&&(!d||a!==d);){if(wysihtml.dom.domNode(a).test(b))return a;a=a.parentNode}return null}}(),wysihtml.dom.getPastedHtml=function(a){var b;return wysihtml.browser.supportsModernPaste()&&a.clipboardData&&(wysihtml.lang.array(a.clipboardData.types).contains("text/html")?b=a.clipboardData.getData("text/html"):wysihtml.lang.array(a.clipboardData.types).contains("text/plain")&&(b=wysihtml.lang.string(a.clipboardData.getData("text/plain")).escapeHTML(!0,!0))),b},wysihtml.dom.getPastedHtmlWithDiv=function(a,b){var c=a.selection.getBookmark(),d=a.element.ownerDocument,e=d.createElement("DIV"),f=a.getScrollPos();d.body.appendChild(e),e.style.width="1px",e.style.height="1px",e.style.overflow="hidden",e.style.position="absolute",e.style.top=f.y+"px",e.style.left=f.x+"px",e.setAttribute("contenteditable","true"),e.focus(),setTimeout(function(){var d;a.selection.setBookmark(c),d=e.innerHTML,d&&/^<br\/?>$/i.test(d.trim())&&(d=!1),b(d),e.parentNode.removeChild(e)},0)},wysihtml.dom.getStyle=function(){function a(a){return a.replace(c,function(a){return a.charAt(1).toUpperCase()})}var b={"float":"styleFloat"in document.createElement("div").style?"styleFloat":"cssFloat"},c=/\-[a-z]/g;return function(c){return{from:function(d){if(d.nodeType===wysihtml.ELEMENT_NODE){var e=d.ownerDocument,f=b[c]||a(c),g=d.style,h=d.currentStyle,i=g[f];if(i)return i;if(h)try{return h[f]}catch(j){}var k,l,m=e.defaultView||e.parentWindow,n=("height"===c||"width"===c)&&"TEXTAREA"===d.nodeName;return m.getComputedStyle?(n&&(k=g.overflow,g.overflow="hidden"),l=m.getComputedStyle(d,null).getPropertyValue(c),n&&(g.overflow=k||""),l):void 0}}}}}(),wysihtml.dom.getTextNodes=function(a,b){var c=[];for(a=a.firstChild;a;a=a.nextSibling)3==a.nodeType?b&&/^\s*$/.test(a.innerText||a.textContent)||c.push(a):c=c.concat(wysihtml.dom.getTextNodes(a,b));return c},function(a){function b(a){return a._wysihtml_identifier||(a._wysihtml_identifier=d++)}var c={},d=1;a.dom.hasElementWithClassName=function(d,e){if(!a.browser.supportsNativeGetElementsByClassName())return!!d.querySelector("."+e);var f=b(d)+":"+e,g=c[f];return g||(g=c[f]=d.getElementsByClassName(e)),g.length>0}}(wysihtml),wysihtml.dom.hasElementWithTagName=function(){function a(a){return a._wysihtml_identifier||(a._wysihtml_identifier=c++)}var b={},c=1;return function(c,d){var e=a(c)+":"+d,f=b[e];return f||(f=b[e]=c.getElementsByTagName(d)),f.length>0}}(),wysihtml.dom.insert=function(a){return{after:function(b){b.parentNode.insertBefore(a,b.nextSibling)},before:function(b){b.parentNode.insertBefore(a,b)},into:function(b){b.appendChild(a)}}},wysihtml.dom.insertCSS=function(a){return a=a.join("\n"),{into:function(b){var c=b.createElement("style");c.type="text/css",c.styleSheet?c.styleSheet.cssText=a:c.appendChild(b.createTextNode(a));var d=b.querySelector("head link");if(d)return void d.parentNode.insertBefore(c,d);var e=b.querySelector("head");e&&e.appendChild(c)}}},wysihtml.dom.isLoadedImage=function(a){try{return a.complete&&!a.mozMatchesSelector(":-moz-broken")}catch(b){if(a.complete&&"complete"===a.readyState)return!0}},function(a){a.dom.lineBreaks=function(b){function c(a){return"BR"===a.nodeName}function d(b){return c(b)?!0:"block"===a.dom.getStyle("display").from(b)?!0:!1}return{add:function(c){var e=b.ownerDocument,f=a.dom.domNode(b).next({ignoreBlankTexts:!0}),g=a.dom.domNode(b).prev({ignoreBlankTexts:!0});f&&!d(f)&&a.dom.insert(e.createElement("br")).after(b),g&&!d(g)&&a.dom.insert(e.createElement("br")).before(b)},remove:function(d){var e=a.dom.domNode(b).next({ignoreBlankTexts:!0}),f=a.dom.domNode(b).prev({ignoreBlankTexts:!0});e&&c(e)&&e.parentNode.removeChild(e),f&&c(f)&&f.parentNode.removeChild(f)}}}}(wysihtml),wysihtml.dom.observe=function(a,b,c){b="string"==typeof b?[b]:b;for(var d,e,f=0,g=b.length;g>f;f++)e=b[f],a.addEventListener?a.addEventListener(e,c,!1):(d=function(b){"target"in b||(b.target=b.srcElement),b.preventDefault=b.preventDefault||function(){this.returnValue=!1},b.stopPropagation=b.stopPropagation||function(){this.cancelBubble=!0},c.call(a,b)},a.attachEvent("on"+e,d));return{stop:function(){for(var e,f=0,g=b.length;g>f;f++)e=b[f],a.removeEventListener?a.removeEventListener(e,c,!1):a.detachEvent("on"+e,d)}}},wysihtml.dom.parse=function(a,b){function c(a,b){wysihtml.lang.object(t).merge(s).merge(b.rules).get();var c,f,g,h=b.context||a.ownerDocument||document,i=h.createDocumentFragment(),j="string"==typeof a,k=!1;for(b.clearInternals===!0&&(k=!0),c=j?wysihtml.dom.getAsDom(a,h):a,t.selectors&&e(c,t.selectors);c.firstChild;)g=c.firstChild,f=d(g,b.cleanUp,k,b.uneditableClass),f&&i.appendChild(f),g!==f&&c.removeChild(g);if(b.unjoinNbsps)for(var l=wysihtml.dom.getTextNodes(i),m=l.length;m--;)l[m].nodeValue=l[m].nodeValue.replace(/([\S\u00A0])\u00A0/gi,"$1 ");return c.innerHTML="",c.appendChild(i),j?wysihtml.quirks.getCorrectInnerHTML(c):c}function d(a,b,c,e){var f,g,h,i,j=a.nodeType,k=a.childNodes,l=k.length,m=p[j],n=0;if(e&&1===j&&wysihtml.dom.hasClass(a,e))return a;if(g=m&&m(a,c),!g){if(g===!1){for(f=a.ownerDocument.createDocumentFragment(),n=l;n--;)k[n]&&(h=d(k[n],b,c,e),h&&(k[n]===h&&n--,f.insertBefore(h,f.firstChild)));return i=wysihtml.dom.getStyle("display").from(a),""===i&&(i=wysihtml.lang.array(u).contains(a.tagName)?"block":""),wysihtml.lang.array(["block","flex","table"]).contains(i)&&f.appendChild(a.ownerDocument.createElement("br")),wysihtml.lang.array(["div","pre","p","table","td","th","ul","ol","li","dd","dl","footer","header","section","h1","h2","h3","h4","h5","h6"]).contains(a.nodeName.toLowerCase())&&a.parentNode.lastChild!==a&&(a.nextSibling&&3===a.nextSibling.nodeType&&/^\s/.test(a.nextSibling.nodeValue)||f.appendChild(a.ownerDocument.createTextNode(" "))),f.normalize&&f.normalize(),f}return null}for(n=0;l>n;n++)k[n]&&(h=d(k[n],b,c,e),h&&(k[n]===h&&n--,g.appendChild(h)));if(b&&g.nodeName.toLowerCase()===q&&(!g.childNodes.length||/^\s*$/gi.test(g.innerHTML)&&(c||"_wysihtml-temp-placeholder"!==a.className&&"rangySelectionBoundary"!==a.className)||!g.attributes.length)){for(f=g.ownerDocument.createDocumentFragment();g.firstChild;)f.appendChild(g.firstChild);return f.normalize&&f.normalize(),f}return g.normalize&&g.normalize(),g}function e(a,b){var c,d,e;for(c in b)if(b.hasOwnProperty(c)){wysihtml.lang.object(b[c]).isFunction()?d=b[c]:"string"==typeof b[c]&&z[b[c]]&&(d=z[b[c]]),e=a.querySelectorAll(c);for(var f=e.length;f--;)d(e[f])}}function f(a,b){var c,d,e,f=t.tags,h=a.nodeName.toLowerCase(),j=a.scopeName;if(a._wysihtml)return null;if(a._wysihtml=1,"wysihtml-temp"===a.className)return null;if(j&&"HTML"!=j&&(h=j+":"+h),"outerHTML"in a&&(wysihtml.browser.autoClosesUnclosedTags()||"P"!==a.nodeName||"</p>"===a.outerHTML.slice(-4).toLowerCase()||(h="div")),h in f){if(c=f[h],!c||c.remove)return null;if(c.unwrap)return!1;c="string"==typeof c?{rename_tag:c}:c}else{if(!a.firstChild)return null;c={rename_tag:q}}if(c.one_of_type&&!g(a,t,c.one_of_type,b)){if(!c.remove_action)return null;if("unwrap"===c.remove_action)return!1;if("rename"!==c.remove_action)return null;e=c.remove_action_rename_to||q}return d=a.ownerDocument.createElement(e||c.rename_tag||h),m(a,d,c,b),i(a,d,c),a=null,d.normalize&&d.normalize(),d}function g(a,b,c,d){var e,f;if("SPAN"===a.nodeName&&!d&&("_wysihtml-temp-placeholder"===a.className||"rangySelectionBoundary"===a.className))return!0;for(f in c)if(c.hasOwnProperty(f)&&b.type_definitions&&b.type_definitions[f]&&(e=b.type_definitions[f],h(a,e)))return!0;return!1}function h(a,b){var c,d,e,f,g,h=a.getAttribute("class"),i=a.getAttribute("style");if(b.methods)for(var j in b.methods)if(b.methods.hasOwnProperty(j)&&y[j]&&y[j](a))return!0;if(h&&b.classes){h=h.replace(/^\s+/g,"").replace(/\s+$/g,"").split(r),c=h.length;for(var k=0;c>k;k++)if(b.classes[h[k]])return!0}if(i&&b.styles){i=i.split(";");for(d in b.styles)if(b.styles.hasOwnProperty(d))for(var l=i.length;l--;)if(g=i[l].split(":"),g[0].replace(/\s/g,"").toLowerCase()===d&&(b.styles[d]===!0||1===b.styles[d]||wysihtml.lang.array(b.styles[d]).contains(g[1].replace(/\s/g,"").toLowerCase())))return!0}if(b.attrs)for(e in b.attrs)if(b.attrs.hasOwnProperty(e)&&(f=wysihtml.dom.getAttribute(a,e),"string"==typeof f&&f.search(b.attrs[e])>-1))return!0;return!1}function i(a,b,c){var d,e;if(c&&c.keep_styles)for(d in c.keep_styles)if(c.keep_styles.hasOwnProperty(d)){if(e="float"===d?a.style.styleFloat||a.style.cssFloat:a.style[d],c.keep_styles[d]instanceof RegExp&&!c.keep_styles[d].test(e))continue;"float"===d?b.style[a.style.styleFloat?"styleFloat":"cssFloat"]=e:a.style[d]&&(b.style[d]=e)}}function j(a,b){var c=[];for(var d in b)b.hasOwnProperty(d)&&0===d.indexOf(a)&&c.push(d);return c}function k(a,b,c,d){var e,f=wysihtml.lang.object(c).isFunction()?c:v[c];return f&&(e=f(b,d),"string"==typeof e)?e:!1}function l(a,b){var c,d,e,f=wysihtml.lang.object(t.attributes||{}).clone(),g=wysihtml.lang.object(f).merge(wysihtml.lang.object(b||{}).clone()).get(),h={},i=wysihtml.dom.getAttributes(a);for(c in g)if(/\*$/.test(c)){e=j(c.slice(0,-1),i);for(var l=0,m=e.length;m>l;l++)d=k(e[l],i[e[l]],g[c],a.nodeName),d!==!1&&(h[e[l]]=d)}else d=k(c,i[c],g[c],a.nodeName),d!==!1&&(h[c]=d);return h}function m(a,b,c,d){var e,f,g,h,i,j={},k=c.set_class,m=c.add_class,n=c.add_style,o=c.set_attributes,p=t.classes,q=0,s=[],u=[],v=[],y=[];if(o&&(j=wysihtml.lang.object(o).clone()),j=wysihtml.lang.object(j).merge(l(a,c.check_attributes)).get(),k&&s.push(k),m)for(h in m)i=x[m[h]],i&&(g=i(wysihtml.dom.getAttribute(a,h)),"string"==typeof g&&s.push(g));if(n)for(h in n)i=w[n[h]],i&&(newStyle=i(wysihtml.dom.getAttribute(a,h)),"string"==typeof newStyle&&u.push(newStyle));if("string"==typeof p&&"any"===p)if(a.getAttribute("class"))if(t.classes_blacklist){for(y=a.getAttribute("class"),y&&(s=s.concat(y.split(r))),e=s.length;e>q;q++)f=s[q],t.classes_blacklist[f]||v.push(f);v.length&&(j["class"]=wysihtml.lang.array(v).unique().join(" "))}else j["class"]=a.getAttribute("class");else s&&s.length>0&&(j["class"]=wysihtml.lang.array(s).unique().join(" "));else{for(d||(p["_wysihtml-temp-placeholder"]=1,p._rangySelectionBoundary=1,p["wysiwyg-tmp-selected-cell"]=1),y=a.getAttribute("class"),y&&(s=s.concat(y.split(r))),e=s.length;e>q;q++)f=s[q],p[f]&&v.push(f);v.length&&(j["class"]=wysihtml.lang.array(v).unique().join(" "))}j["class"]&&d&&(j["class"]=j["class"].replace("wysiwyg-tmp-selected-cell",""),/^\s*$/g.test(j["class"])&&delete j["class"]),u.length&&(j.style=wysihtml.lang.array(u).unique().join(" "));for(h in j)try{b.setAttribute(h,j[h])}catch(z){}j.src&&("undefined"!=typeof j.width&&b.setAttribute("width",j.width),"undefined"!=typeof j.height&&b.setAttribute("height",j.height))}function n(a){var b=a.nextSibling;if(!b||b.nodeType!==wysihtml.TEXT_NODE){var c=a.data.replace(wysihtml.INVISIBLE_SPACE_REG_EXP,"");return a.ownerDocument.createTextNode(c)}b.data=a.data.replace(wysihtml.INVISIBLE_SPACE_REG_EXP,"")+b.data.replace(wysihtml.INVISIBLE_SPACE_REG_EXP,"")}function o(a){return t.comments?a.ownerDocument.createComment(a.nodeValue):void 0}var p={1:f,3:n,8:o},q="span",r=/\s+/,s={tags:{},classes:{}},t={},u=["ADDRESS","BLOCKQUOTE","CENTER","DIR","DIV","DL","FIELDSET","FORM","H1","H2","H3","H4","H5","H6","ISINDEX","MENU","NOFRAMES","NOSCRIPT","OL","P","PRE","TABLE","UL"],v={url:function(){var a=/^https?:\/\//i;return function(b){return b&&b.match(a)?b.replace(a,function(a){return a.toLowerCase()}):null}}(),src:function(){var a=/^(\/|https?:\/\/)/i;return function(b){return b&&b.match(a)?b.replace(a,function(a){return a.toLowerCase()}):null}}(),href:function(){var a=/^(#|\/|https?:\/\/|mailto:|tel:)/i;return function(b){return b&&b.match(a)?b.replace(a,function(a){return a.toLowerCase()}):null}}(),alt:function(){var a=/[^ a-z0-9_\-]/gi;return function(b,c){return b?b.replace(a,""):"IMG"===c?"":null}}(),numbers:function(){var a=/\D/g;return function(b){return b=(b||"").replace(a,""),b||null}}(),dimension:function(){var a=/\D*(\d+)(\.\d+)?\s?(%)?\D*/;return function(b){return b=(b||"").replace(a,"$1$2$3"),b||null}}(),any:function(){return function(a){return a?a:null}}()},w={align_text:function(){var a={left:"text-align: left;",right:"text-align: right;",center:"text-align: center;"};return function(b){return a[String(b).toLowerCase()]}}()},x={align_img:function(){var a={left:"wysiwyg-float-left",right:"wysiwyg-float-right"};return function(b){return a[String(b).toLowerCase()]}}(),align_text:function(){var a={left:"wysiwyg-text-align-left",right:"wysiwyg-text-align-right",center:"wysiwyg-text-align-center",justify:"wysiwyg-text-align-justify"};return function(b){return a[String(b).toLowerCase()]}}(),clear_br:function(){var a={left:"wysiwyg-clear-left",right:"wysiwyg-clear-right",both:"wysiwyg-clear-both",all:"wysiwyg-clear-both"};return function(b){return a[String(b).toLowerCase()]}}(),size_font:function(){var a={1:"text-font-normal",2:"text-font-largest",3:"text-font-large",4:"text-font-medium",5:"text-font-small",6:"text-font-smallest"};return function(b){return a[String(b).charAt(0)]}}()},y={has_visible_contet:function(){var a,b=["img","video","picture","br","script","noscript","style","table","iframe","object","embed","audio","svg","input","button","select","textarea","canvas"];return function(c){if(a=(c.innerText||c.textContent).replace(/\s/g,""),a&&a.length>0)return!0;for(var d=b.length;d--;)if(c.querySelector(b[d]))return!0;return c.offsetWidth&&c.offsetWidth>0&&c.offsetHeight&&c.offsetHeight>0?!0:!1}}()},z={unwrap:function(a){wysihtml.dom.unwrap(a)},remove:function(a){a.parentNode.removeChild(a)}};return c(a,b)},wysihtml.dom.query=function(a,b){var c,d=[];a.nodeType&&(a=[a]);for(var e=0,f=a.length;f>e;e++)if(c=a[e].querySelectorAll(b))for(var g=c.length;g--;d.unshift(c[g]));return d},wysihtml.dom.removeEmptyTextNodes=function(a){for(var b,c=wysihtml.lang.array(a.childNodes).get(),d=c.length,e=0;d>e;e++)b=c[e],b.nodeType===wysihtml.TEXT_NODE&&/^[\n\r]*$/.test(b.data)&&b.parentNode.removeChild(b)},wysihtml.dom.removeInvisibleSpaces=function(a){for(var b=wysihtml.dom.getTextNodes(a),c=b.length;c--;)b[c].nodeValue=b[c].nodeValue.replace(wysihtml.INVISIBLE_SPACE_REG_EXP,"")},wysihtml.dom.renameElement=function(a,b){for(var c,d=a.ownerDocument.createElement(b);c=a.firstChild;)d.appendChild(c);return wysihtml.dom.copyAttributes(["align","className"]).from(a).to(d),a.parentNode&&a.parentNode.replaceChild(d,a),d},wysihtml.dom.replaceWithChildNodes=function(a){if(a.parentNode){for(;a.firstChild;)a.parentNode.insertBefore(a.firstChild,a);a.parentNode.removeChild(a)}},function(a){function b(b){return"block"===a.getStyle("display").from(b)}function c(a){return"BR"===a.nodeName}function d(a){var b=a.ownerDocument.createElement("br");a.appendChild(b)}function e(a,e){if(a.nodeName.match(/^(MENU|UL|OL)$/)){var f,g,h,i,j,k,l,m=a.ownerDocument,n=m.createDocumentFragment(),o=wysihtml.dom.domNode(a).prev({ignoreBlankTexts:!0}),p=wysihtml.dom.domNode(a).next({ignoreBlankTexts:!0}),q=a.lastElementChild||a.lastChild;if(e)for(!o||b(o)||c(o)||d(n);k=a.firstElementChild||a.firstChild;){for(g=k.lastChild,l=k===q;f=k.firstChild;)h=f===g,i=(!l||p&&!b(p))&&h&&!b(f)&&!c(f),n.appendChild(f),i&&d(n);k.parentNode.removeChild(k)}else for(;k=a.firstElementChild||a.firstChild;){if(k.querySelector&&k.querySelector("div, p, ul, ol, menu, blockquote, h1, h2, h3, h4, h5, h6"))for(;f=k.firstChild;)n.appendChild(f);else{for(j=m.createElement("p");f=k.firstChild;)j.appendChild(f);n.appendChild(j)}k.parentNode.removeChild(k)}a.parentNode.replaceChild(n,a)}}a.resolveList=e}(wysihtml.dom),function(a){var b=document,c=["parent","top","opener","frameElement","frames","localStorage","globalStorage","sessionStorage","indexedDB"],d=["open","close","openDialog","showModalDialog","alert","confirm","prompt","openDatabase","postMessage","XMLHttpRequest","XDomainRequest"],e=["referrer","write","open","close"];a.dom.Sandbox=Base.extend({constructor:function(b,c){this.callback=b||a.EMPTY_FUNCTION,this.config=a.lang.object({}).merge(c).get(),this.config.className||(this.config.className="wysihtml-sandbox"),this.editableArea=this._createIframe()},insertInto:function(a){"string"==typeof a&&(a=b.getElementById(a)),a.appendChild(this.editableArea)},getIframe:function(){return this.editableArea},getWindow:function(){this._readyError()},getDocument:function(){this._readyError()},destroy:function(){var a=this.getIframe();a.parentNode.removeChild(a)},_readyError:function(){throw new Error("wysihtml.Sandbox: Sandbox iframe isn't loaded yet")},_createIframe:function(){var c=this,d=b.createElement("iframe");return d.className=this.config.className,a.dom.setAttributes({security:"restricted",allowtransparency:"true",frameborder:0,width:0,height:0,marginwidth:0,marginheight:0}).on(d),a.browser.throwsMixedContentWarningWhenIframeSrcIsEmpty()&&(d.src="javascript:'<html></html>'"),d.onload=function(){d.onreadystatechange=d.onload=null,c._onLoadIframe(d)},d.onreadystatechange=function(){/loaded|complete/.test(d.readyState)&&(d.onreadystatechange=d.onload=null,c._onLoadIframe(d))},d},_onLoadIframe:function(f){if(a.dom.contains(b.documentElement,f)){var g=this,h=f.contentWindow,i=f.contentWindow.document,j=b.characterSet||b.charset||"utf-8",k=this._getHtml({charset:j,stylesheets:this.config.stylesheets});if(i.open("text/html","replace"),i.write(k),i.close(),this.getWindow=function(){return f.contentWindow},this.getDocument=function(){return f.contentWindow.document},h.onerror=function(a,b,c){throw new Error("wysihtml.Sandbox: "+a,b,c)},!a.browser.supportsSandboxedIframes()){var l,m;for(l=0,m=c.length;m>l;l++)this._unset(h,c[l]);for(l=0,m=d.length;m>l;l++)this._unset(h,d[l],a.EMPTY_FUNCTION);for(l=0,m=e.length;m>l;l++)this._unset(i,e[l]);this._unset(i,"cookie","",!0)}a.polyfills&&a.polyfills(h,i).apply(),this.loaded=!0,setTimeout(function(){g.callback(g)},0)}},_getHtml:function(b){var c,d=b.stylesheets,e="",f=0;if(d="string"==typeof d?[d]:d)for(c=d.length;c>f;f++)e+='<link rel="stylesheet" href="'+d[f]+'">';return b.stylesheets=e,a.lang.string('<!DOCTYPE html><html><head><meta charset="#{charset}">#{stylesheets}</head><body></body></html>').interpolate(b)},_unset:function(b,c,d,e){try{b[c]=d}catch(f){}try{b.__defineGetter__(c,function(){return d})}catch(f){}if(e)try{b.__defineSetter__(c,function(){})}catch(f){}if(!a.browser.crashesWhenDefineProperty(c))try{var g={get:function(){return d}};e&&(g.set=function(){}),Object.defineProperty(b,c,g)}catch(f){}}})}(wysihtml),function(){var a={className:"class"};wysihtml.dom.setAttributes=function(b){return{on:function(c){for(var d in b)c.setAttribute(a[d]||d,b[d])}}}}(),wysihtml.dom.setStyles=function(a){return{on:function(b){var c=b.style;if("string"==typeof a)return void(c.cssText+=";"+a);for(var d in a)"float"===d?(c.cssFloat=a[d],c.styleFloat=a[d]):c[d]=a[d]}}},function(a){a.simulatePlaceholder=function(b,c,d,e){var f=e||"wysihtml-placeholder",g=function(){var b=c.element.offsetWidth>0&&c.element.offsetHeight>0;c.hasPlaceholderSet()&&(c.clear(),c.element.focus(),b&&setTimeout(function(){var a=c.selection.getSelection();a.focusNode&&a.anchorNode||c.selection.selectNode(c.element.firstChild||c.element)},0)),c.placeholderSet=!1,a.removeClass(c.element,f)},h=function(){c.isEmpty()&&!c.placeholderSet&&(c.placeholderSet=!0,c.setValue(d,!1),a.addClass(c.element,f))};b.on("set_placeholder",h).on("unset_placeholder",g).on("focus:composer",g).on("paste:composer",g).on("blur:composer",h),h()}}(wysihtml.dom),function(a){var b=document.documentElement;"textContent"in b?(a.setTextContent=function(a,b){a.textContent=b},a.getTextContent=function(a){return a.textContent}):"innerText"in b?(a.setTextContent=function(a,b){a.innerText=b},a.getTextContent=function(a){return a.innerText}):(a.setTextContent=function(a,b){a.nodeValue=b},a.getTextContent=function(a){return a.nodeValue})}(wysihtml.dom),wysihtml.dom.unwrap=function(a){var b=[];if(a.parentNode){for(;a.lastChild;)b.unshift(a.lastChild),wysihtml.dom.insert(a.lastChild).after(a);a.parentNode.removeChild(a)}return b},wysihtml.quirks.cleanPastedHTML=function(){var a=function(a){var b=wysihtml.lang.string(a).trim(),c=b.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");return new RegExp("^((?!^"+c+"$).)*$","i")},b=function(b,c){var d,e,f=wysihtml.lang.object(b).clone(!0);for(d in f.tags)if(f.tags.hasOwnProperty(d)&&f.tags[d].keep_styles)for(e in f.tags[d].keep_styles)f.tags[d].keep_styles.hasOwnProperty(e)&&c[e]&&(f.tags[d].keep_styles[e]=a(c[e]));return f},c=function(a,b){var c;if(!a)return null;for(var d=0,e=a.length;e>d;d++)if(a[d].condition||(c=a[d].set),a[d].condition&&a[d].condition.test(b))return a[d].set;return c};return function(a,d){var e,f={color:wysihtml.dom.getStyle("color").from(d.referenceNode),fontSize:wysihtml.dom.getStyle("font-size").from(d.referenceNode)},g=b(c(d.rules,a)||{},f),h=a.indexOf("</html>");return-1!==h&&(a=a.slice(0,h+7)),e=wysihtml.dom.parse(a,{rules:g,cleanUp:!0,context:d.referenceNode.ownerDocument,uneditableClass:d.uneditableClass,clearInternals:!0,unjoinNbsps:!0})}}(),wysihtml.quirks.ensureProperClearing=function(){var a=function(){var a=this;setTimeout(function(){var b=a.innerHTML.toLowerCase();("<p>&nbsp;</p>"==b||"<p>&nbsp;</p><p>&nbsp;</p>"==b)&&(a.innerHTML="")},0)};return function(b){wysihtml.dom.observe(b.element,["cut","keydown"],a)}}(),function(a){var b="%7E";a.quirks.getCorrectInnerHTML=function(c){var d=c.innerHTML;if(-1===d.indexOf(b))return d;var e,f,g,h,i=c.querySelectorAll("[href*='~'], [src*='~']");for(h=0,g=i.length;g>h;h++)e=i[h].href||i[h].src,f=a.lang.string(e).replace("~").by(b),d=a.lang.string(d).replace(f).by(e);return d}}(wysihtml),function(a){var b="wysihtml-quirks-redraw";a.quirks.redraw=function(c){a.dom.addClass(c,b),a.dom.removeClass(c,b);try{var d=c.ownerDocument;d.execCommand("italic",!1,null),d.execCommand("italic",!1,null)}catch(e){}}}(wysihtml),function(a){function b(a){var b,c;for(b in d)if(d.hasOwnProperty(b)&&(c=d[b],c.regex.test(a)))return c}function c(a){var c=b(a);return c?c.name:void 0}var d={rgba:{regex:/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([\d\.]+)\s*\)/i,name:"rgba"},rgb:{regex:/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/i,name:"rgb"},hex6:{regex:/^#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])/i,name:"hex",radix:16},hex3:{regex:/^#([0-9a-f])([0-9a-f])([0-9a-f])/i,name:"hex",radix:16}},e=function(a){return new RegExp("(^|\\s|;)"+a+"\\s*:\\s*[^;$]+","gi")};a.quirks.styleParser={getColorParseMethod:b,getColorFormat:c,parseColor:function(c,f){var g,h,i,j,k,l=c;if(f){if(g=e(f),!(h=c.match(g)))return!1;h=h.pop().split(":")[1],l=a.lang.string(h).trim()}return(i=b(l))&&(j=l.match(i.regex))?(k=i.radix||10,i===d.hex3?(j.shift(),j.push(1),a.lang.array(j).map(function(a,b){return 3>b?parseInt(a,k)*k+parseInt(a,k):parseFloat(a)})):(j.shift(),j[3]||j.push(1),a.lang.array(j).map(function(a,b){return 3>b?parseInt(a,k):parseFloat(a)}))):!1},unparseColor:function(a,b){var c=16;return"hex"===b?(a[0].toString(c)+a[1].toString(c)+a[2].toString(c)).toUpperCase():"hash"===b?"#"+(a[0].toString(c)+a[1].toString(c)+a[2].toString(c)).toUpperCase():"rgb"===b?"rgb("+a[0]+","+a[1]+","+a[2]+")":"rgba"===b?"rgba("+a[0]+","+a[1]+","+a[2]+","+a[3]+")":"csv"===b?a[0]+","+a[1]+","+a[2]+","+a[3]:a[3]&&1!==a[3]?"rgba("+a[0]+","+a[1]+","+a[2]+","+a[3]+")":"rgb("+a[0]+","+a[1]+","+a[2]+")"},parseFontSize:function(b){var c=b.match(e("font-size"));return c?a.lang.string(c[c.length-1].split(":")[1]).trim():!1}}}(wysihtml),function(a){function b(a){var b=0;if(a.parentNode)do b+=a.offsetTop||0,a=a.offsetParent;while(a);return b}function c(a,b){for(var c=0;b!==a;)if(c++,b=b.parentNode,!b)throw new Error("not a descendant of ancestor!");return c}function d(a,b){return 3===a.nodeType?a:a.childNodes[b]||a}function e(b){var c=document.createElement("span"),d=function(a){b.removeEventListener("mouseup",d),b.removeEventListener("keydown",d),b.removeEventListener("touchstart",d),b.removeEventListener("focus",d),b.removeEventListener("blur",d),b.removeEventListener("paste",e),b.removeEventListener("drop",e),b.removeEventListener("beforepaste",e),c&&c.parentNode&&c.parentNode.removeChild(c)},e=function(a){c&&c.parentNode&&setTimeout(d,0)};return c.appendChild(b.ownerDocument.createTextNode(a.INVISIBLE_SPACE)),c.className="_wysihtml-temp-caret-fix",c.style.display="block",c.style.minWidth="1px",c.style.height="0px",b.addEventListener("mouseup",d),b.addEventListener("keydown",d),b.addEventListener("touchstart",d),b.addEventListener("focus",d),b.addEventListener("blur",d),b.addEventListener("paste",e),b.addEventListener("drop",e),b.addEventListener("beforepaste",e),c}function f(a){if(!a.canSurroundContents())for(var b=a.commonAncestorContainer,d=c(b,a.startContainer),e=c(b,a.endContainer);!a.canSurroundContents();)d>e?(a.setStartBefore(a.startContainer),d=c(b,a.startContainer)):(a.setEndAfter(a.endContainer),e=c(b,a.endContainer))}var g=a.dom;a.Selection=Base.extend({constructor:function(a,b,c){rangy.init(),this.editor=a,this.composer=a.composer,this.doc=this.composer.doc,this.win=this.composer.win,this.contain=b,this.unselectableClass=c||!1},getBookmark:function(){var a=this.getRange();return a&&a.cloneRange()},setBookmark:function(a){a&&this.setSelection(a)},setBefore:function(a){var b=rangy.createRange(this.doc);return b.setStartBefore(a),b.setEndBefore(a),this.setSelection(b)},createTemporaryCaretSpaceAfter:function(b){var c=this.doc.createElement("span"),d=this.doc.createTextNode(a.INVISIBLE_SPACE),e=function(b){var d;this.contain.removeEventListener("mouseup",e),this.contain.removeEventListener("keydown",g),this.contain.removeEventListener("touchstart",e),this.contain.removeEventListener("focus",e),this.contain.removeEventListener("blur",e),this.contain.removeEventListener("paste",f),this.contain.removeEventListener("drop",f),this.contain.removeEventListener("beforepaste",f),c&&c.parentNode&&(c.innerHTML=c.innerHTML.replace(a.INVISIBLE_SPACE_REG_EXP,""),/[^\s]+/.test(c.innerHTML)?(d=c.lastChild,a.dom.unwrap(c),this.setAfter(d)):c.parentNode.removeChild(c))}.bind(this),f=function(a){c&&c.parentNode&&setTimeout(e,0)},g=function(a){8===a.which||91===a.which||17===a.which||86===a.which&&(a.ctrlKey||a.metaKey)||e()};return c.className="_wysihtml-temp-caret-fix",c.style.position="absolute",c.style.display="block",c.style.minWidth="1px",c.style.zIndex="99999",c.appendChild(d),b.parentNode.insertBefore(c,b.nextSibling),this.setBefore(d),this.contain.addEventListener("mouseup",e),this.contain.addEventListener("keydown",g),this.contain.addEventListener("touchstart",e),this.contain.addEventListener("focus",e),this.contain.addEventListener("blur",e),this.contain.addEventListener("paste",f),this.contain.addEventListener("drop",f),this.contain.addEventListener("beforepaste",f),c},setAfter:function(b,c,d){var e,f=this.win,g=rangy.createRange(this.doc),h=function(){var d=b.parentNode,g=d?d.childNodes[d.childNodes.length-1]:null;if(!e||g===b&&1===b.nodeType&&"block"===f.getComputedStyle(b).display)if(c){var h=this.doc.createTextNode(a.INVISIBLE_SPACE);b.parentNode.insertBefore(h,b.nextSibling),this.selectNode(h),setTimeout(function(){h&&h.parentNode&&h.parentNode.removeChild(h)},0)}else this.createTemporaryCaretSpaceAfter(b)}.bind(this);if(g.setStartAfter(b),g.setEndAfter(b),document.activeElement&&document.activeElement===this.composer.element)e=this.setSelection(g),h(),d&&d(e);else{var i=this.composer.getScrollPos();this.composer.element.focus(),this.composer.setScrollPos(i),setTimeout(function(){e=this.setSelection(g),h(),d&&d(e)}.bind(this),0)}},selectNode:function(b,c){var d=rangy.createRange(this.doc),e=b.nodeType===a.ELEMENT_NODE,f="canHaveHTML"in b?b.canHaveHTML:"IMG"!==b.nodeName,h=e?b.innerHTML:b.data,i=""===h||h===a.INVISIBLE_SPACE,j=g.getStyle("display").from(b),k="block"===j||"list-item"===j;if(i&&e&&f&&!c)try{b.innerHTML=a.INVISIBLE_SPACE}catch(l){}f?d.selectNodeContents(b):d.selectNode(b),f&&i&&e?d.collapse(k):f&&i&&(d.setStartAfter(b),d.setEndAfter(b)),this.setSelection(d)},getSelectedNode:function(a){var b,c;return a&&this.doc.selection&&"Control"===this.doc.selection.type&&(c=this.doc.selection.createRange(),c&&c.length)?c.item(0):(b=this.getSelection(this.doc),b.focusNode===b.anchorNode?b.focusNode:(c=this.getRange(this.doc),c?c.commonAncestorContainer:this.doc.body))},fixSelBorders:function(){var a=this.getRange();f(a),this.setSelection(a)},getSelectedOwnNodes:function(a){for(var b=this.getOwnRanges(),c=[],d=0,e=b.length;e>d;d++)c.push(b[d].commonAncestorContainer||this.doc.body);return c},findNodesInSelection:function(b){for(var c,d=this.getOwnRanges(),e=[],f=0,g=d.length;g>f;f++)c=d[f].getNodes([1],function(c){return a.lang.array(b).contains(c.nodeName)}),e=e.concat(c);return e},filterElements:function(a){for(var b,c=this.getOwnRanges(),d=[],e=0,f=c.length;f>e;e++)b=c[e].getNodes([1],function(b){return a(b,c[e])}),d=d.concat(b);return d},containsUneditable:function(){for(var a=this.getOwnUneditables(),b=this.getSelection(),c=0,d=a.length;d>c;c++)if(b.containsNode(a[c]))return!0;return!1},deleteContents:function(){var a=this.getRange();this.deleteRangeContents(a),this.setSelection(a)},deleteRangeContents:function(b){var c,d,e,f;if(this.unselectableClass){(c=a.dom.getParentElement(b.startContainer,{query:"."+this.unselectableClass},!1,this.contain))&&b.setStartBefore(c),(d=a.dom.getParentElement(b.endContainer,{query:"."+this.unselectableClass},!1,this.contain))&&b.setEndAfter(d),e=b.getNodes([1],function(b){return a.dom.hasClass(b,this.unselectableClass)}.bind(this));for(var g=e.length;g--;)try{f=new CustomEvent("wysihtml:uneditable:delete"),e[g].dispatchEvent(f)}catch(h){}}b.deleteContents()},getCaretNode:function(){var a=this.getSelection();return a&&a.anchorNode?d(a.anchorNode,a.anchorOffset):null},getPreviousNode:function(b,c){var e;if(!b){var f=this.getSelection();b=f&&f.anchorNode?d(f.anchorNode,f.anchorOffset):null}if(b===this.contain)return!1;var g,h=b.previousSibling;return h===this.contain?!1:(h&&3!==h.nodeType&&1!==h.nodeType?h=this.getPreviousNode(h,c):h&&3===h.nodeType&&/^\s*$/.test(h.textContent)?h=this.getPreviousNode(h,c):c&&h&&1===h.nodeType?(e=a.dom.getStyle("display").from(h),a.lang.array(["BR","HR","IMG"]).contains(h.nodeName)||a.lang.array(["block","inline-block","flex","list-item","table"]).contains(e)||!/^[\s]*$/.test(h.innerHTML)||(h=this.getPreviousNode(h,c))):h||b===this.contain||(g=b.parentNode,g!==this.contain&&(h=this.getPreviousNode(g,c))),h!==this.contain?h:!1)},getNodesNearCaret:function(){if(!this.isCollapsed())throw"Selection must be caret when using selection.getNodesNearCaret()";var a,b,c,d,e=this.getOwnRanges();return e&&e.length>0?(1===e[0].startContainer.nodeType?(a=e[0].startContainer.childNodes[e[0].startOffset-1],a||0!==e[0].startOffset?a&&(b=a.previousSibling,c=a.nextSibling):c=e[0].startContainer.childNodes[0]):(0===e[0].startOffset&&e[0].startContainer.previousSibling?(a=e[0].startContainer.previousSibling,3===a.nodeType&&(d=a.data.length)):(a=e[0].startContainer,d=e[0].startOffset),b=a.previousSibling,c=a.nextSibling),{caretNode:a,prevNode:b,nextNode:c,textOffset:d}):null},getSelectionParentsByTag:function(b){for(var c,d=this.getSelectedOwnNodes(),e=[],f=0,g=d.length;g>f;f++)c=d[f].nodeName&&"LI"===d[f].nodeName?d[f]:a.dom.getParentElement(d[f],{query:"li"},!1,this.contain),c&&e.push(c);return e.length?e:null},getRangeToNodeEnd:function(){if(this.isCollapsed()){var a,b,c,d=this.getRange();if(d)return a=d.startContainer,b=d.startOffset,c=rangy.createRange(this.doc),c.selectNodeContents(a),c.setStart(a,b),c}},getRangeToNodeBeginning:function(){if(this.isCollapsed()){var a=this.getRange(),b=a.startContainer,c=a.startOffset,d=rangy.createRange(this.doc);return d.selectNodeContents(b),d.setEnd(b,c),d}},caretIsInTheEndOfNode:function(a){var b,c,d,e,f=(rangy.createRange(this.doc),this.getSelection(),this.getRangeToNodeEnd());return f?(b=f.cloneContents(),c=b.textContent,/^\s*$/.test(c)?a?(d=this.getRangeToNodeBeginning().cloneContents(),
  e=d.textContent,!/[\u00A0 ][\s\uFEFF]*$/.test(e)):!0:!1):!1},caretIsFirstInSelection:function(b){var c=rangy.createRange(this.doc),e=this.getSelection(),f=this.getRange(),g=d(f.startContainer,f.startOffset);if(g){if(g.nodeType===a.TEXT_NODE){if(!g.parentNode)return!1;if(!this.isCollapsed()||g.parentNode.firstChild!==g&&!a.dom.domNode(g.previousSibling).is.block())return!1;var h=this.win.getComputedStyle(g.parentNode).whiteSpace;return"pre"===h||"pre-wrap"===h?0===f.startOffset:0==g.data.substr(0,f.startOffset).replace(/\u00a0/g,"x").trim().length}return b&&a.dom.domNode(g).is.lineBreak()?!0:(c.selectNodeContents(this.getRange().commonAncestorContainer),c.collapse(!0),this.isCollapsed()&&(c.startContainer===e.anchorNode||c.endContainer===e.anchorNode)&&c.startOffset===e.anchorOffset)}},caretIsInTheBeginnig:function(b){var c=this.getSelection(),d=c.anchorNode,e=c.anchorOffset;return b&&d?0===e&&(d.nodeName&&d.nodeName===b.toUpperCase()||a.dom.getParentElement(d.parentNode,{query:b},1)):d?0===e&&!this.getPreviousNode(d,!0):void 0},getBeforeSelection:function(b){var c,d,e=this.getSelection(),f=e.isBackwards()?e.focusNode:e.anchorNode,g=e.isBackwards()?e.focusOffset:e.anchorOffset,h=this.createRange();if(f&&3===f.nodeType&&/^\s*$/.test(f.data.slice(0,g))&&(g=0),d=a.dom.getParentElement(f,{query:"._wysihtml-temp-caret-fix"},1),d&&(f=d.parentNode,g=Array.prototype.indexOf.call(f.childNodes,d)),f){if(g>0)return 3===f.nodeType?(h.setStart(f,0),h.setEnd(f,g),{type:"text",range:h,offset:g,node:f}):(h.setStartBefore(f.childNodes[0]),c=f.childNodes[g-1],h.setEndAfter(c),{type:"element",range:h,offset:g,node:c});if(h.setStartAndEnd(f,0),b){var i=this.getPreviousNode(f,!0),j=null;if(i&&(j=1===i.nodeType&&a.dom.hasClass(i,this.unselectableClass)?i:a.dom.domNode(i).lastLeafNode()),j)return{type:"leafnode",range:h,offset:g,node:j}}return{type:"none",range:h,offset:g,node:f}}return null},executeAndRestoreRangy:function(a,b){var c=rangy.saveSelection(this.win);if(c)try{a()}catch(d){setTimeout(function(){throw d},0)}else a();rangy.restoreSelection(c)},executeAndRestore:function(b,c){var d,e,f,h,i,j,k,l,m=this.doc.body,n=c&&m.scrollTop,o=c&&m.scrollLeft,p="_wysihtml-temp-placeholder",q='<span class="'+p+'">'+a.INVISIBLE_SPACE+"</span>",r=this.getRange(!0);if(!r)return void b(m,m);r.collapsed||(k=r.cloneRange(),j=k.createContextualFragment(q),k.collapse(!1),k.insertNode(j),k.detach()),i=r.createContextualFragment(q),r.insertNode(i),j&&(d=this.contain.querySelectorAll("."+p),r.setStartBefore(d[0]),r.setEndAfter(d[d.length-1])),this.setSelection(r);try{b(r.startContainer,r.endContainer)}catch(s){setTimeout(function(){throw s},0)}if(d=this.contain.querySelectorAll("."+p),d&&d.length){l=rangy.createRange(this.doc),f=d[0].nextSibling,d.length>1&&(h=d[d.length-1].previousSibling),h&&f?(l.setStartBefore(f),l.setEndAfter(h)):(e=this.doc.createTextNode(a.INVISIBLE_SPACE),g.insert(e).after(d[0]),l.setStartBefore(e),l.setEndAfter(e)),this.setSelection(l);for(var t=d.length;t--;)d[t].parentNode.removeChild(d[t])}else this.contain.focus();c&&(m.scrollTop=n,m.scrollLeft=o);try{d.parentNode.removeChild(d)}catch(u){}},set:function(a,b){var c=rangy.createRange(this.doc);c.setStart(a,b||0),this.setSelection(c)},insertHTML:function(a){var b,c,d=this.getRange(),e=this.doc.createElement("DIV"),f=this.doc.createDocumentFragment();if(d){for(d.deleteContents(),e.innerHTML=a,b=e.lastChild;e.firstChild;)f.appendChild(e.firstChild);for(d.insertNode(f),c=this.contain.lastChild;c&&3===c.nodeType&&c.previousSibling&&/^\s*$/.test(c.data);)c=c.previousSibling;b&&(c&&b===c&&1===b.nodeType&&this.contain.appendChild(this.doc.createElement("br")),this.setAfter(b))}},insertNode:function(a){var b=this.getRange();b&&(b.deleteContents(),b.insertNode(a))},canAppendChild:function(a){var b,c,d=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],e=this.getRange();return b=a||e.startContainer,b&&(c=(b.tagName||b.nodeName).toLowerCase()),-1===d.indexOf(c)},splitElementAtCaret:function(b,c){var d,e,f,g,h,i=this.getSelection();if(i.rangeCount>0){d=i.getRangeAt(0).cloneRange(),d.setEndAfter(b),e=d.extractContents(),h=e.childNodes;for(var j=h.length;j--;)a.dom.domNode(h[j]).is.visible()||e.removeChild(h[j]);b.parentNode.insertBefore(e,b.nextSibling),c?(f=c.firstChild||c,g=c.lastChild||c,b.parentNode.insertBefore(c,b.nextSibling),f&&g&&(d.setStartBefore(f),d.setEndAfter(g),this.setSelection(d))):(d.setStartAfter(b),d.setEndAfter(b)),a.dom.domNode(b).is.visible()||(""===a.dom.getTextContent(b)?b.parentNode.removeChild(b):b.parentNode.replaceChild(this.doc.createTextNode(" "),b))}},surround:function(a){var b,c=this.getOwnRanges(),d=[];if(0==c.length)return d;for(var e=c.length;e--;){b=this.doc.createElement(a.nodeName),d.push(b),a.className&&(b.className=a.className),a.cssStyle&&b.setAttribute("style",a.cssStyle);try{c[e].surroundContents(b),this.selectNode(b)}catch(f){b.appendChild(c[e].extractContents()),c[e].insertNode(b)}}return d},scrollIntoView:function(){var c,d=this.doc,e=5,f=d.documentElement.scrollHeight>d.documentElement.offsetHeight,g=d._wysihtmlScrollIntoViewElement=d._wysihtmlScrollIntoViewElement||function(){var b=d.createElement("span");return b.innerHTML=a.INVISIBLE_SPACE,b}();f&&(this.insertNode(g),c=b(g),g.parentNode.removeChild(g),c>=d.body.scrollTop+d.documentElement.offsetHeight-e&&(d.body.scrollTop=c))},selectLine:function(){var b=rangy.createRange();a.browser.supportsSelectionModify()?this._selectLine_W3C():b.nativeRange&&b.nativeRange.getBoundingClientRect&&this._selectLineUniversal()},includeRangyRangeHelpers:function(){var a=this.getSelection(),b=a.getRangeAt(0),c=function(a){return a&&1===a.nodeType&&a.classList.contains("rangySelectionBoundary")},d=function(a){return 1===a.nodeType?a.childNodes&&a.childNodes.length||0:a.data&&a.data.length||0},e=1===a.anchorNode.nodeType?a.anchorNode.childNodes[a.anchorOffset]:a.anchorNode,f=1===a.focusNode.nodeType?a.focusNode.childNodes[a.focusOffset]:a.focusNode;f&&a.focusOffset===d(f)&&f.nextSibling&&c(f.nextSibling)&&b.setEndAfter(f.nextSibling),e&&0===a.anchorOffset&&e.previousSibling&&c(e.previousSibling)&&b.setStartBefore(e.previousSibling),b.select()},_selectLine_W3C:function(){var a=this.win.getSelection(),b=[a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset];a.modify("move","left","lineboundary"),a.modify("extend","right","lineboundary"),a.anchorNode===b[0]&&a.anchorOffset===b[1]&&a.focusNode===b[2]&&a.focusOffset===b[3]?this._selectLineUniversal():this.includeRangyRangeHelpers()},toLineBoundary:function(b,c){if(c="undefined"==typeof c?!1:c,a.browser.supportsSelectionModify()){var d=this.win.getSelection();d.modify("extend",b,"lineboundary"),c&&("left"===b?d.collapseToStart():"right"===b&&d.collapseToEnd())}},getRangeRect:function(a){var b,c=(this.doc.createTextNode("i"),this.doc.createTextNode("i"));return a.collapsed?(a.insertNode(c),a.selectNode(c),b=a.nativeRange.getBoundingClientRect(),a.deleteContents()):b=a.nativeRange.getBoundingClientRect(),b},_selectLineUniversal:function(){var b,c,d,e,f,g,h=this.getSelection(),i=h.getRangeAt(0),j=0,k=this,l=function(b){return b&&1===b.nodeType&&("block"===k.win.getComputedStyle(b).display||a.lang.array(["BR","HR"]).contains(b.nodeName))},m=function(a){var b=a;if(b)for(;b&&(1===b.nodeType&&b.classList.contains("rangySelectionBoundary")||3===b.nodeType&&/^\s*$/.test(b.data));)b=b.previousSibling;return b};c=i.cloneRange(),d=i.cloneRange(),i.collapsed&&(3===i.startContainer.nodeType&&i.startOffset<i.startContainer.data.length?i.moveEnd("character",1):1===i.startContainer.nodeType&&i.startContainer.childNodes[i.startOffset]&&3===i.startContainer.childNodes[i.startOffset].nodeType&&i.startContainer.childNodes[i.startOffset].data.length>0?i.moveEnd("character",1):i.startOffset>0&&(3===i.startContainer.nodeType||1===i.startContainer.nodeType&&!l(m(i.startContainer.childNodes[i.startOffset-1])))&&i.moveStart("character",-1)),i.collapsed||i.insertNode(this.doc.createTextNode(a.INVISIBLE_SPACE)),b=i.nativeRange.getBoundingClientRect();do e=i.moveStart("character",-1),f=i.nativeRange.getBoundingClientRect(),f&&Math.floor(f.top)===Math.floor(b.top)||(i.moveStart("character",1),g=!0),j++;while(0!==e&&!g&&2e3>j);if(j=0,g=!1,b=i.nativeRange.getBoundingClientRect(),i.endContainer!==this.contain||this.contain.lastChild&&this.contain.childNodes[i.endOffset]!==this.contain.lastChild)do e=i.moveEnd("character",1),f=i.nativeRange.getBoundingClientRect(),f&&Math.floor(f.bottom)===Math.floor(b.bottom)||(i.moveEnd("character",-1),i.endContainer&&1===i.endContainer.nodeType&&i.endContainer.childNodes[i.endOffset]&&1===i.endContainer.childNodes[i.endOffset].nodeType&&"BR"===i.endContainer.childNodes[i.endOffset].nodeName&&i.endContainer.childNodes[i.endOffset].previousSibling&&(1===i.endContainer.childNodes[i.endOffset].previousSibling.nodeType?i.setEnd(i.endContainer.childNodes[i.endOffset].previousSibling,i.endContainer.childNodes[i.endOffset].previousSibling.childNodes.length):3===i.endContainer.childNodes[i.endOffset].previousSibling.nodeType&&i.setEnd(i.endContainer.childNodes[i.endOffset].previousSibling,i.endContainer.childNodes[i.endOffset].previousSibling.data.length)),g=!0),j++;while(0!==e&&!g&&2e3>j);i.select(),this.includeRangyRangeHelpers()},getText:function(){var a=this.getSelection();return a?a.toString():""},getNodes:function(a,b){var c=this.getRange();return c?c.getNodes(Array.isArray(a)?a:[a],b):[]},getOwnNodes:function(a,b,c){for(var d=this.getOwnRanges(),e=[],f=0,g=d.length;g>f;f++)d[f]&&(c&&d[f].splitBoundaries(),e=e.concat(d[f].getNodes(Array.isArray(a)?a:[a],b)));return e},fixRangeOverflow:function(a){if(this.contain&&this.contain.firstChild&&a){var b=a.compareNode(this.contain);if(2!==b)1===b&&a.setStartBefore(this.contain.firstChild),0===b&&a.setEndAfter(this.contain.lastChild),3===b&&(a.setStartBefore(this.contain.firstChild),a.setEndAfter(this.contain.lastChild));else if(this._detectInlineRangeProblems(a)){var c=a.endContainer.previousElementSibling;c&&a.setEnd(c,this._endOffsetForNode(c))}}},_endOffsetForNode:function(a){var b=document.createRange();return b.selectNodeContents(a),b.endOffset},_detectInlineRangeProblems:function(a){var b=g.compareDocumentPosition(a.startContainer,a.endContainer);return 0==a.endOffset&&4&b},getRange:function(a){var b=this.getSelection(),c=b&&b.rangeCount&&b.getRangeAt(0);return a!==!0&&this.fixRangeOverflow(c),c},getOwnUneditables:function(){var b=g.query(this.contain,"."+this.unselectableClass),c=g.query(b,"."+this.unselectableClass);return a.lang.array(b).without(c)},getOwnRanges:function(){var a,b=[],c=this.getRange();if(c&&b.push(c),this.unselectableClass&&this.contain&&c){var d,e=this.getOwnUneditables();if(e.length>0)for(var f=0,g=e.length;g>f;f++){a=[];for(var h=0,i=b.length;i>h;h++){if(b[h])switch(b[h].compareNode(e[f])){case 2:break;case 3:d=b[h].cloneRange(),d.setEndBefore(e[f]),a.push(d),d=b[h].cloneRange(),d.setStartAfter(e[f]),a.push(d);break;default:a.push(b[h])}b=a}}}return b},getSelection:function(){return rangy.getSelection(this.win)},setSelection:function(a){var b=rangy.getSelection(this.win);return b.setSingleRange(a),b&&b.anchorNode&&b.focusNode?b:null},selectAll:function(){var b,c=this.createRange(),d=this.composer,f=this,g=e(this.composer.element),h=e(this.composer.element),i=function(){c.setStart(d.element,0),c.setEnd(d.element,d.element.childNodes.length),b=f.setSelection(c)},j=function(){return!b||b.nativeSelection&&b.nativeSelection.type&&("Caret"===b.nativeSelection.type||"None"===b.nativeSelection.type)};a.dom.removeInvisibleSpaces(this.composer.element),i(),this.composer.element.firstChild&&j()&&(this.composer.element.appendChild(g),i(),j()&&(g.parentNode.removeChild(g),this.composer.element.insertBefore(h,this.composer.element.firstChild),i(),j()&&(this.composer.element.appendChild(g),i())))},createRange:function(){return rangy.createRange(this.doc)},isCollapsed:function(){return this.getSelection().isCollapsed},getHtml:function(){return this.getSelection().toHtml()},getPlainText:function(){return this.getSelection().toString()},isEndToEndInNode:function(b){var c=this.getRange(),d=c.commonAncestorContainer,e=c.startContainer,f=c.endContainer;if(d.nodeType===a.TEXT_NODE&&(d=d.parentNode),e.nodeType===a.TEXT_NODE&&!/^\s*$/.test(e.data.substr(c.startOffset)))return!1;if(f.nodeType===a.TEXT_NODE&&!/^\s*$/.test(f.data.substr(c.endOffset)))return!1;for(;e&&e!==d;){if(e.nodeType!==a.TEXT_NODE&&!a.dom.contains(d,e))return!1;if(a.dom.domNode(e).prev({ignoreBlankTexts:!0}))return!1;e=e.parentNode}for(;f&&f!==d;){if(f.nodeType!==a.TEXT_NODE&&!a.dom.contains(d,f))return!1;if(a.dom.domNode(f).next({ignoreBlankTexts:!0}))return!1;f=f.parentNode}return a.lang.array(b).contains(d.nodeName)?d:!1},isInThisEditable:function(){var b=this.getSelection(),c=b.focusNode,d=b.anchorNode;return c&&1!==c.nodeType&&(c=c.parentNode),d&&1!==d.nodeType&&(d=d.parentNode),d&&c&&(a.dom.contains(this.composer.element,c)||this.composer.element===c)&&(a.dom.contains(this.composer.element,d)||this.composer.element===d)},deselect:function(){var a=this.getSelection();a&&a.removeAllRanges()}})}(wysihtml),wysihtml.Commands=Base.extend({constructor:function(a){this.editor=a,this.composer=a.composer,this.doc=this.composer.doc},support:function(a){return wysihtml.browser.supportsCommand(this.doc,a)},exec:function(a,b){var c=wysihtml.commands[a],d=wysihtml.lang.array(arguments).get(),e=c&&c.exec,f=null;if(this.composer.hasPlaceholderSet()&&!wysihtml.lang.array(["styleWithCSS","enableObjectResizing","enableInlineTableEditing"]).contains(a)&&(this.composer.element.innerHTML="",this.composer.selection.selectNode(this.composer.element)),this.editor.fire("beforecommand:composer"),e)d.unshift(this.composer),f=e.apply(c,d);else try{f=this.doc.execCommand(a,!1,b)}catch(g){}return this.editor.fire("aftercommand:composer"),f},remove:function(a,b){var c=wysihtml.commands[a],d=wysihtml.lang.array(arguments).get(),e=c&&c.remove;return e?(d.unshift(this.composer),e.apply(c,d)):void 0},state:function(a,b){var c=wysihtml.commands[a],d=wysihtml.lang.array(arguments).get(),e=c&&c.state;if(e)return d.unshift(this.composer),e.apply(c,d);try{return this.doc.queryCommandState(a)}catch(f){return!1}},stateValue:function(a){var b=wysihtml.commands[a],c=wysihtml.lang.array(arguments).get(),d=b&&b.stateValue;return d?(c.unshift(this.composer),d.apply(b,c)):!1}}),function(a){function b(b){return a.lang.object({}).merge(c).merge({attribute:b}).get()}var c={nodeName:"A",toggle:!1};a.commands.createLink={exec:function(c,d,e){var f=b(e);if(c.selection.isCollapsed()&&!this.state(c,d)){var g=c.doc.createTextNode(f.attribute.href);c.selection.insertNode(g),c.selection.selectNode(g)}a.commands.formatInline.exec(c,d,f)},state:function(b,d){return a.commands.formatInline.state(b,d,c)}}}(wysihtml),function(a){function b(a){return{nodeName:a.nodeName||null,className:a.classRegExp?null:a.className||null,classRegExp:a.classRegExp||null,styleProperty:a.styleProperty||null}}function c(a,b){return 3===a.nodeType?a:a.childNodes[b]||a}function d(a){return a&&1===a.nodeType&&"BR"===a.nodeName}function e(a,b){return a&&1===a.nodeType&&"block"===b.win.getComputedStyle(a).display}function f(a){return a&&1===a.nodeType&&a.classList.contains("rangySelectionBoundary")}function g(a,b){return d(a)||e(a,b)}function h(b,c){a.dom.removeInvisibleSpaces(b.element);for(var d,e=b.element,f=e.querySelectorAll(D),g=b.config.classNames.uneditableContainer+[""].concat(D.split(",")).join(", "+b.config.classNames.uneditableContainer+" "),h=e.querySelectorAll(g),i=a.lang.array(f).without(h),j=i.length;j--;)""!==i[j].innerHTML.replace(/[\uFEFF]/g,"")||0!==c.length&&i[j]===c[c.length-1]||(d=a.lang.array(c).indexOf(i[j]),d>-1&&c.splice(d,1),i[j].parentNode.removeChild(i[j]));return c}function i(a){return a.config.useLineBreaks?"DIV":"P"}function j(a,b,c){for(var d=a,e=null;d&&b&&d!==b;)1===d.nodeType&&d.matches(c?D:C)&&(e=d),d=d.parentNode;return e}function k(a,b){for(var c,d,e,f=a,g=null;f&&b&&f!==b;)1===f.nodeType&&f.matches(E)&&(d=f,null===g?(g=f.cloneNode(!1),c=g):(e=f.cloneNode(!1),e.appendChild(g),g=e)),f=f.parentNode;return{parent:d,outerNode:g,innerNode:c}}function l(b,c,d){return b||(b=d.doc.createElement(c.nodeName||i(d)),b.appendChild(d.doc.createTextNode(a.INVISIBLE_SPACE))),c.nodeName&&b.nodeName!==c.nodeName&&(b=B.renameElement(b,c.nodeName)),c.classRegExp&&(b.className=b.className.replace(c.classRegExp,"")),c.className&&b.classList.add(c.className),c.styleProperty&&"undefined"!=typeof c.styleValue&&(b.style[a.browser.fixStyleKey(c.styleProperty)]=c.styleValue),b}function m(b,c,d){var e,f=b.previousSibling,g=b.nextSibling,h=!1;c.styleProperty&&(b.style[a.browser.fixStyleKey(c.styleProperty)]=""),c.className&&b.classList.remove(c.className),c.classRegExp&&(b.className=b.className.replace(c.classRegExp,"")),null!==b.getAttribute("class")&&""===b.getAttribute("class").trim()&&b.removeAttribute("class"),c.nodeName&&b.nodeName.toLowerCase()===c.nodeName.toLowerCase()&&(e=b.getAttribute("style"),e&&""!==e.trim()?b=B.renameElement(b,i(d)):(B.unwrap(b),h=!0)),null!==b.getAttribute("style")&&""===b.getAttribute("style").trim()&&b.removeAttribute("style"),h&&u(f,g,d)}function n(b){for(var c,d,e=b.querySelectorAll(D)||[],f=e.length;f--;)c=a.dom.domNode(e[f]).next({nodeTypes:[1,3],ignoreBlankTexts:!0}),d=a.dom.domNode(e[f]).prev({nodeTypes:[1,3],ignoreBlankTexts:!0}),c&&1!==c.nodeType&&"BR"!==c.nodeName&&""!==(e[f].innerHTML||e[f].nodeValue||"").trim()&&e[f].parentNode.insertBefore(e[f].ownerDocument.createElement("BR"),c),c&&1!==c.nodeType&&"BR"!==c.nodeName&&""!==(e[f].innerHTML||e[f].nodeValue||"").trim()&&e[f].parentNode.insertBefore(e[f].ownerDocument.createElement("BR"),c),a.dom.unwrap(e[f])}function o(a,b){var c,d=a.startContainer,e=a.endContainer;return d&&1===d.nodeType&&d===e?void(d.firstChild===d.lastChild&&1===a.endOffset&&d!==b.element&&"LI"!==d.nodeName&&"TD"!==d.nodeName&&(a.setStartBefore(d),a.setEndAfter(e))):d&&1===d.nodeType&&3===e.nodeType?void(d.firstChild===e&&a.endOffset===e.data.length&&d!==b.element&&"LI"!==d.nodeName&&"TD"!==d.nodeName&&a.setEndAfter(d)):e&&1===e.nodeType&&3===d.nodeType?void(e.firstChild===d&&0===a.startOffset&&e!==b.element&&"LI"!==e.nodeName&&"TD"!==e.nodeName&&a.setStartBefore(e)):d&&3===d.nodeType&&d===e&&1===d.parentNode.childNodes.length?void(a.endOffset==e.data.length&&0===a.startOffset&&(c=d.parentNode,c!==b.element&&"LI"!==c.nodeName&&"TD"!==c.nodeName&&(a.setStartBefore(c),a.setEndAfter(c)))):void 0}function p(b){for(var c,d,e,f,g,h,i=[],j=0,k=b.length;k>j;j++)if(1===b[j].startContainer.nodeType&&b[j].startContainer.matches("ul, ol")&&b[j].setStart(b[j].startContainer.childNodes[b[j].startOffset],0),1===b[j].endContainer.nodeType&&b[j].endContainer.matches("ul, ol")&&(h=b[j].endContainer.childNodes[Math.max(b[j].endOffset-1,0)],h.childNodes&&b[j].setEnd(h,h.childNodes.length)),c=b[j].getNodes([1],function(a){return"LI"===a.nodeName}),c.length>0){for(d=0,e=c.length;e>d;d++)g=b[j].compareNode(c[d]),(g===b[j].NODE_AFTER||g===b[j].NODE_INSIDE)&&(f=b[j].cloneRange(),h=a.dom.domNode(c[d]).prev({nodeTypes:[1]}),h?f.setEnd(h,h.childNodes.length):c[d].closest("ul, ol")?f.setEndBefore(c[d].closest("ul, ol")):f.setEndBefore(c[d]),i.push(f),b[j].setStart(c[d],0)),(g===b[j].NODE_BEFORE||g===b[j].NODE_INSIDE)&&(f=b[j].cloneRange(),f.setEnd(c[d],c[d].childNodes.length),i.push(f),h=a.dom.domNode(c[d]).next({nodeTypes:[1]}),h?b[j].setStart(h,0):c[d].closest("ul, ol")?b[j].setStartAfter(c[d].closest("ul, ol")):b[j].setStartAfter(c[d]));i.push(b[j])}else i.push(b[j]);return i}function q(b,c,d){var e=b?a.lang.object(b).clone(!0):null;return e&&(e.nodeName=e.nodeName||c||i(d)),e}function r(b,c,d,e){var f,h,i,l,m,n=c.startContainer,e=e||j(n,d.element,!0);if(e)h=b.firstChild,i=b.lastChild,d.selection.splitElementAtCaret(e,b),m=a.dom.domNode(i).next({nodeTypes:[1,3],ignoreBlankTexts:!0}),l=a.dom.domNode(h).prev({nodeTypes:[1,3],ignoreBlankTexts:!0}),h&&!g(h,d)&&l&&!g(l,d)&&h.parentNode.insertBefore(d.doc.createElement("br"),h),i&&!g(i,d)&&m&&!g(m,d)&&m.parentNode.insertBefore(d.doc.createElement("br"),m);else if(f=k(n,d.element),f.outerNode&&f.innerNode&&f.parent){if(1===b.childNodes.length){for(;b.firstChild.firstChild;)f.innerNode.appendChild(b.firstChild.firstChild);b.firstChild.appendChild(f.outerNode)}d.selection.splitElementAtCaret(f.parent,b)}else{var o=b.firstChild,p=b.lastChild;c.insertNode(b),c.setStartBefore(o),c.setEndAfter(p)}}function s(b,d,e){for(var f,h,i=b.cloneRange(),j=c(i.startContainer,i.startOffset).previousSibling,k=c(i.endContainer,i.endOffset).nextSibling,l=i.extractContents(),m=e.doc.createDocumentFragment(),o=!0;l.firstChild;){if(1===l.firstChild.nodeType&&l.firstChild.matches(D)){n(l.firstChild),f=a.dom.unwrap(l.firstChild),f.length>0&&(m.lastChild&&(1!==m.lastChild.nodeType||!g(m.lastChild,e))||!m.lastChild&&j&&(1!==j.nodeType||g(j,e)))&&m.appendChild(e.doc.createElement("BR"));for(var p=0,q=f.length;q>p;p++)m.appendChild(f[p]);f.length>0&&(1===m.lastChild.nodeType&&g(m.lastChild,e)||(k||m.lastChild!==l.lastChild)&&m.appendChild(e.doc.createElement("BR")))}else m.appendChild(l.firstChild);o=!1}return h=a.lang.array(m.childNodes).get(),r(m,i,e),h}function t(b,c,e){var f=b&&a.dom.domNode(b).prev({nodeTypes:[1,3],ignoreBlankTexts:!0});d(c)&&c.parentNode.removeChild(c),!d(b)||f&&1===f.nodeType&&"block"===e.win.getComputedStyle(f).display||b.parentNode.removeChild(b)}function u(a,b,c){var e;a&&f(a)&&(a=a.previousSibling),b&&f(b)&&(b=b.nextSibling),e=a&&a.previousSibling,a&&(1!==a.nodeType||"block"!==c.win.getComputedStyle(a).display&&!d(a))&&a.parentNode&&a.parentNode.insertBefore(c.doc.createElement("br"),a.nextSibling),b&&(1!==b.nodeType||"block"!==c.win.getComputedStyle(b).display)&&b.parentNode&&b.parentNode.insertBefore(c.doc.createElement("br"),b)}function v(d,e,f,g){var h,i,k=e?b(e):null,m=d.cloneRange(),o=m.startContainer,p=c(m.startContainer,m.startOffset),s=c(m.endContainer,m.endOffset),u=m.startContainer!==p||3!==p.nodeType||F(p,m.startOffset)?a.dom.domNode(p).prev({nodeTypes:[1,3],ignoreBlankTexts:!0}):p,v=1===m.endContainer.nodeType&&m.endContainer.childNodes[m.endOffset]===s&&(1===s.nodeType||!G(s,m.endOffset)&&!a.dom.domNode(s).is.rangyBookmark())||m.endContainer===s&&3===s.nodeType&&!G(s,m.endOffset)?s:a.dom.domNode(s).next({nodeTypes:[1,3],ignoreBlankTexts:!0}),w=m.extractContents(),x=g.doc.createDocumentFragment(),y=k?a.dom.getParentElement(o,k,null,g.element):null,z=!f||!e||"BLOCKQUOTE"===e.nodeName&&"BLOCKQUOTE"===f,A=y||j(o,g.element,z);if(a.dom.domNode(v).is.rangyBookmark()&&(s=v,v=s.nextSibling),H(w),e&&"BLOCKQUOTE"===e.nodeName){var B=l(null,e,g);B.appendChild(w),x.appendChild(B),i=[B]}else{if(w.firstChild)for(;w.firstChild;)if(1==w.firstChild.nodeType&&w.firstChild.matches(D))l(w.firstChild,e,g),w.firstChild.matches(C)&&n(w.firstChild),x.appendChild(w.firstChild);else{for(h=l(null,q(e,f,g),g);w.firstChild&&(1!==w.firstChild.nodeType||!w.firstChild.matches(D));)1==w.firstChild.nodeType&&h.matches(C)&&n(w.firstChild),h.appendChild(w.firstChild);x.appendChild(h)}else x.appendChild(l(null,e,g));i=a.lang.array(x.childNodes).get()}return r(x,m,g,A),t(u,v,g),i.length>0&&("undefined"==typeof i[i.length-1].lastChild||a.dom.domNode(i[i.length-1].lastChild).is.rangyBookmark())&&i[i.length-1].appendChild(g.doc.createElement("br")),i}function w(b,c){var d=a.dom.getParentElement(b,{query:D},null,c.element);return d?d.nodeName:null}function x(b,c){var d,e=a.dom.getParentElement(b.selection.getOwnRanges()[0].startContainer,{query:C+", "+(c?c.toLowerCase():"div")},null,b.element);e?(d=b.selection.createRange(),d.selectNode(e),b.selection.setSelection(d)):b.isEmpty()||b.selection.selectLine()}function y(a,b){var c=b.selection.createRange(),d=a[a.length-1],e=1===d.nodeType&&d.childNodes?0|d.childNodes.length:d.length||0;c.setStart(a[0],0),c.setEnd(d,e),c.select()}function z(a,b,c){var d,e=b.selection.getOwnRanges(),f=[];e=p(e);for(var g=e.length;g--;)o(e[g],b),d=w(e[g].startContainer,b),f="remove"===a?f.concat(s(e[g],d,b)):f.concat(v(e[g],c,d,b));return f}function A(a){return"string"==typeof a&&(a={nodeName:a.toUpperCase()}),a}var B=a.dom,C="h1, h2, h3, h4, h5, h6, p, pre",D="h1, h2, h3, h4, h5, h6, p, pre, div, blockquote",E="b, big, i, small, tt, abbr, acronym, cite, code, dfn, em, kbd, strong, samp, var, a, bdo, br, q, span, sub, sup, button, label, textarea, input, select, u",F=function(a,b){var c=a.data?a.data.slice(0,b):"";return/^\s*$/.test(c)},G=function(a,b){var c=a.data?a.data.slice(b):"";return/^\s*$/.test(c)},H=function(a){if(a){for(;a.firstChild&&3===a.firstChild.nodeType&&/^\s*$/.test(a.firstChild.data)&&a.lastChild!==a.firstChild;)a.removeChild(a.firstChild);for(;a.lastChild&&3===a.lastChild.nodeType&&/^\s*$/.test(a.lastChild.data)&&a.lastChild!==a.firstChild;)a.removeChild(a.lastChild);a.firstChild&&1===a.firstChild.nodeType&&"BR"===a.firstChild.nodeName&&a.lastChild!==a.firstChild&&a.removeChild(a.firstChild),a.lastChild&&1===a.lastChild.nodeType&&"BR"===a.lastChild.nodeName&&a.lastChild!==a.firstChild&&a.removeChild(a.lastChild)}};a.commands.formatBlock={exec:function(b,c,d){d=A(d);var e,f,g,i=b.selection.getOwnRanges();if(1===i.length){for(e=i[0],f=e.startContainer;f&&"SPAN"!==f.tagName&&"P"!=f.tagName;)f=f.parentNode;f&&"SPAN"===f.tagName&&(g=f.className)}var j,k,l=[];if(d&&d.toggle&&(k=this.state(b,c,d)),k){j=rangy.saveSelection(b.win);for(var n=0,o=k.length;o>n;n++)m(k[n],d,b)}else b.selection.isCollapsed()&&(j=rangy.saveSelection(b.win),x(b,d&&d.nodeName?d.nodeName.toUpperCase():void 0)),l=d?z("apply",b,d):z("remove",b);l=h(b,l),j?rangy.restoreSelection(j):y(l,b),a.commands.formatInline.cleanEditor(b,g)},remove:function(a,b,c){c=A(c);var d,e;a.selection.isCollapsed()&&(e=rangy.saveSelection(a.win),x(a,c&&c.nodeName?c.nodeName.toUpperCase():void 0)),d=z("remove",a),d=h(a,d),e?rangy.restoreSelection(e):y(d,a)},state:function(b,c,d){d=A(d);for(var e,f=b.selection.filterElements(function(b){return a.dom.domNode(b).test(d||{query:D})}.bind(this)),g=b.selection.getSelectedOwnNodes(),h=0,i=g.length;i>h;h++)e=B.getParentElement(g[h],d||{query:D},null,b.element),e&&-1===f.indexOf(e)&&f.push(e);return 0===f.length?!1:f}}}(wysihtml),function(a){function b(a){return/^\s*$/.test(a.className)}function c(a){return!a.getAttribute("style")||/^\s*$/.test(a.getAttribute("style"))}function d(b){var c=a.dom.getAttributes(b);return a.lang.object(c).isEmpty()}function e(b,c){var d,e,f,g;return 1!==b.nodeType||1!==c.nodeType?!1:b.nodeName!==c.nodeName?!1:(d=b.className.trim().replace(/\s+/g," ").split(" "),e=c.className.trim().replace(/\s+/g," ").split(" "),a.lang.array(d).without(e).length>0?!1:(f=a.dom.getAttributes(b),g=a.dom.getAttributes(c),f.length===g.length&&a.lang.object(a.lang.object(f).difference(g)).isEmpty()?!0:!1))}function f(b,c){var d=c&&c.nodeName||F,e=b.ownerDocument.createElement(d);if(c.classRegExp&&(e.className=e.className.replace(c.classRegExp,"")),c.className&&e.classList.add(c.className),c.styleProperty&&"undefined"!=typeof c.styleValue&&(e.style[a.browser.fixStyleKey(c.styleProperty)]=c.styleValue),c.attribute)if("object"==typeof c.attribute)for(var f in c.attribute)c.attribute.hasOwnProperty(f)&&e.setAttribute(f,c.attribute[f]);else"undefined"!=typeof c.attributeValue&&e.setAttribute(c.attribute,c.attributeValue);return e}function g(a,b){for(var c in a)if(a.hasOwnProperty(c)&&(void 0===typeof b[c]||b[c]!==a[c]))return!1;return!0}function h(b,c,d){var e,f=a.dom.getAttributes(b),h=g(c,f);a.lang.object(f).difference(c);if(h&&d!==!1)for(e in c)c.hasOwnProperty(e)&&b.removeAttribute(e);else for(e in c)c.hasOwnProperty(e)&&b.setAttribute(e,c[e])}function i(e,f){var g,i,j;f.className&&(f.toggle!==!1&&e.classList.contains(f.className)?e.classList.remove(f.className):(f.classRegExp&&(e.className=e.className.replace(f.classRegExp,"")),e.classList.add(f.className)),b(e)&&e.removeAttribute("class")),f.styleProperty&&(f.toggle!==!1&&e.style[a.browser.fixStyleKey(f.styleProperty)].trim().replace(/, /g,",")===f.styleValue?e.style[a.browser.fixStyleKey(f.styleProperty)]="":e.style[a.browser.fixStyleKey(f.styleProperty)]=f.styleValue),c(e)&&e.removeAttribute("style"),f.attribute&&("object"==typeof f.attribute?g=f.attribute:(g={},g[f.attribute]=f.attributeValue||""),h(e,g,f.toggle)),i=f.nodeName?H[f.nodeName.toLowerCase()]||f.nodeName.toLowerCase():null,j=i?a.dom.domNode(e).test({query:i}):!1,(!f.nodeName||f.nodeName===F||j)&&(f.toggle!==!1&&j||!f.nodeName&&e.nodeName===F)&&b(e)&&c(e)&&d(e)&&a.dom.unwrap(e)}function j(b,c){var d=[];return b.isCollapsed()||(d=d.concat(b.getOwnNodes([3],function(b){return!a.dom.domNode(b).is.emptyTextNode()},c))),d}function k(a,b,c,d){var e=a,f=d?b:l(b);do{if(1===e.nodeType&&m(e,f))return e;e=e.parentNode}while(e&&e!==c);return null}function l(a){return{nodeName:a.nodeName||null,className:a.classRegExp?null:a.className||null,classRegExp:a.classRegExp||null,styleProperty:a.styleProperty||null}}function m(b,c){var d;if(c.nodeName){var e=H[c.nodeName.toLowerCase()]||c.nodeName.toLowerCase();return a.dom.domNode(b).test({query:e})}return d=a.lang.object(c).clone(),d.query=G,a.dom.domNode(b).test(d)}function n(b,c){var d=document.documentElement||document.body,e=d.scrollTop,f=d.scrollLeft;rangy.getSelection(b.win);rangy.getSelection(b.win).removeAllRanges();try{rangy.getSelection(b.win).addRange(c)}catch(g){}b.doc.activeElement&&a.dom.contains(b.element,b.doc.activeElement)||(b.element.focus(),d.scrollTop=e,d.scrollLeft=f,rangy.getSelection(b.win).addRange(c))}function o(a,b){var c=rangy.createRange(b.doc),d=a[a.length-1];a[0]&&d&&(c.setStart(a[0],0),c.setEnd(d,d.length),n(b,c))}function p(a,b,c,d){var e=rangy.createRange(a.doc);b&&(e.setStart(b,c),e.setEnd(b,"undefined"!=typeof d?d:c),n(a,e))}function q(a,b,c){var d,e,f,g=j(a.selection),h=[],i=!1;if(a.selection.isInThisEditable()){if(0===g.length&&a.selection.isCollapsed()){if(f=a.selection.getSelection().anchorNode,!f)return{nodes:[],partial:!1};3===f.nodeType&&(g=[f])}g.length||(e=a.selection.getOwnRanges()[0],e&&(g=[e.endContainer]));for(var l=0,m=g.length;m>l;l++)d=k(g[l],b,a.element,c),d?h.push(d):i=!0}return{nodes:h,partial:i}}function r(a){var b,c,d,e;return a&&(b=a.anchorNode,c=a.anchorOffset,b&&3===b.nodeType&&c>0&&c<b.data.length)?(d=b.data[c-1],e=b.data[c],/\w/.test(d)&&/\w/.test(e)):!1}function s(b){var c,d,e,f,g,h,i=[];if(b&&(c=b.anchorNode,d=g=h=b.anchorOffset,e=c.ownerDocument,f=rangy.createRange(e),c&&3===c.nodeType)){for(;g>0&&/\w/.test(c.data[g-1]);)g--;for(;h<c.data.length&&/\w/.test(c.data[h]);)h++;return f.setStartAndEnd(c,g,h),f.splitBoundaries(),i=f.getNodes([3],function(b){return!a.dom.domNode(b).is.emptyTextNode()}),{wordOffset:d-g,range:f,textNode:i[0]}}return!1}function t(a,b){for(;b.firstChild;)a.appendChild(b.firstChild);b.parentNode.removeChild(b)}function u(a){for(var b=a.length;b--;)a[b]&&a[b].parentNode&&(a[b].nextSibling&&e(a[b],a[b].nextSibling)&&t(a[b],a[b].nextSibling),a[b].previousSibling&&e(a[b],a[b].previousSibling)&&t(a[b].previousSibling,a[b]))}function v(a,b,c){b.length>0&&o(b,a),u(q(a,c).nodes),b.length>0&&o(b,a)}function w(a,b,c,d){p(a,b,c),u(q(a,d).nodes),p(a,b,c)}function x(a,b){var c=f(a,b);a.parentNode.insertBefore(c,a),c.appendChild(a)}function y(b,c,d){var e,f=c.element,g=k(b,d,f);g&&(e=g.cloneNode(!1),a.dom.domNode(b).escapeParent(g,e),i(e,d))}function z(b,c,d){var e=c.element,f=k(b,d,e);f&&a.dom.domNode(b).escapeParent(f)}function A(a,b,c){var d=f(a.endContainer,c);a.surroundContents(d),b.selection.selectNode(d)}function B(b,c,d,e){var f,g,h,j,l=q(b,e,!0),m=b.selection.getSelection();if(c.length){if(l.partial||e.toggle===!1)for(j=c.length;j--;)k(c[j],e,b.element)&&y(c[j],b,e),k(c[j],e,b.element)||x(c[j],e);else for(j=c.length;j--;)y(c[j],b,e);v(b,c,e)}else if(e.toggle!==!1)if(r(m))f=s(m),g=f.textNode,y(f.textNode,b,e),w(b,f.textNode,f.wordOffset,e);else{g=b.doc.createTextNode(a.INVISIBLE_SPACE),h=d.nodes[0].cloneNode(!1),h.appendChild(g),
  b.selection.splitElementAtCaret(d.nodes[0],h),i(h,e),v(b,[g],e);var n=b.selection.getSelection();if(n.anchorNode&&n.focusNode)try{n.collapseToEnd()}catch(o){}}else for(j=d.nodes.length;j--;)i(d.nodes[j],e)}function C(b,c,d,e){var f,g,h,i=b.selection.getSelection();if(c.length){for(h=c.length;h--;)z(c[h],b,e);v(b,c,e)}else{for(f=i.anchorNode,g=i.anchorOffset,h=d.nodes.length;h--;)a.dom.unwrap(d.nodes[h]);w(b,f,g,e)}}function D(a,b,c){var d,e,f=a.selection.getSelection();if(b.length){for(e=b.length;e--;)x(b[e],c);v(a,b,c)}else if(r(f))d=s(f),x(d.textNode,c),w(a,d.textNode,d.wordOffset,c);else{var g=a.selection.getOwnRanges()[0];g&&A(g,a,c)}}function E(a){return a="string"==typeof a?{nodeName:a}:a,a.nodeName&&(a.nodeName=a.nodeName.toUpperCase()),a}var F="SPAN",G="b, big, i, small, tt, abbr, acronym, cite, code, dfn, em, kbd, strong, samp, var, a, bdo, br, q, span, sub, sup, button, label, textarea, input, select, u",H={b:"b, strong",strong:"b, strong",em:"em, i",i:"em, i"};a.commands.formatInline={exec:function(a,b,c){c=E(c),a.element.normalize();var d=j(a.selection,!0),e=q(a,c);e.nodes.length>0?B(a,d,e,c):D(a,d,c),a.element.normalize()},remove:function(a,b,c){c=E(c),a.element.normalize();var d=j(a.selection,!0),e=q(a,c);e.nodes.length>0&&C(a,d,e,c),a.element.normalize()},state:function(a,b,c){c=E(c);var d=q(a,c,!0).nodes;return 0===d.length?!1:d},cleanEditor:function(b,c){function d(a){var b=a.childNodes;if(b&&0===b.length)return!0;for(var c=0;c<b.length;c++)if("span"!==b[c].nodeName&&"BR"!==b[c].nodeName)return!1;return!0}if(b.isEmpty()){var e=b.doc.createElement("P"),f=b.doc.createElement("span");return f.className="text-font-normal",f.innerHTML+="<br>",e.appendChild(f),b.element.innerHTML="",b.element.appendChild(e),void(a.browser.displaysCaretInEmptyContentEditableCorrectly()?b.selection.selectNode(e.firstChild,!0):b.selection.setBefore(e.firstChild.firstChild))}for(var g=b.selection.getBookmark(),h=b.element.getElementsByTagName("P"),i=0;i<h.length;i++){var j=h[i];if(1!==j.childNodes.length)for(var k=j.getElementsByTagName("span"),l=0;l<k.length;l++)if(d(k[l]))if(l!==k.length-1){for(var m=k[l].childNodes.length,n=0;m>n;n++)k[l].parentNode.insertBefore(k[l].childNodes[0],k[l+1]);k[l].parentNode.removeChild(k[l]),l--}else{for(var m=k[l].childNodes.length,o=0;m>o;o++)k[l].parentNode.appendChild(k[l].childNodes[0]);k[l].parentNode.removeChild(k[l]),l--}}for(var p=b.element.getElementsByTagName("span"),q=0;q<p.length;q++){var r=p[q];""==r.innerHTML&&(r.parentNode.removeChild(r),q--)}for(var s=0;s<h.length;s++){var j=h[s];if(0!==j.childNodes.length){if(j.firstChild&&"SPAN"!=j.firstChild.nodeName){var r=b.doc.createElement("span");r.className=c||"text-font-normal",r.innerHTML=j.innerHTML,j.innerHTML="",j.appendChild(r)}}else j.parentNode.removeChild(j),s--}b.selection.setBookmark(g)}}}(wysihtml),function(a){a.commands.indentList={exec:function(a,b,c){var d=a.selection.getSelectionParentsByTag("LI");return d?this.tryToPushLiLevel(d,a.selection):!1},state:function(a,b){return!1},tryToPushLiLevel:function(b,c){var d,e,f,g,h,i=!1;return c.executeAndRestoreRangy(function(){for(var c=b.length;c--;)g=b[c],d="OL"===g.parentNode.nodeName?"OL":"UL",e=g.ownerDocument.createElement(d),f=a.dom.domNode(g).prev({nodeTypes:[a.ELEMENT_NODE]}),h=f?f.querySelector("ul, ol"):null,f&&(h?h.appendChild(g):(e.appendChild(g),f.appendChild(e)),i=!0)}),i}}}(wysihtml),function(a){a.commands.insertHTML={exec:function(a,b,c){a.selection.insertHTML(c)},state:function(){return!1}}}(wysihtml),function(a){var b="<br>"+(a.browser.needsSpaceAfterLineBreak()?" ":"");a.commands.insertLineBreak={exec:function(a,c){a.selection.insertHTML(b)},state:function(){return!1}}}(wysihtml),wysihtml.commands.insertList=function(a){var b=function(a,b){if(a&&a.nodeName){"string"==typeof b&&(b=[b]);for(var c=b.length;c--;)if(a.nodeName===b[c])return!0}return!1},c=function(c,d,e){var f={el:null,other:!1};if(c){var g=a.dom.getParentElement(c,{query:"li"},!1,e.element),h="UL"===d?"OL":"UL";b(c,d)?f.el=c:b(c,h)?f={el:c,other:!0}:g&&(b(g.parentNode,d)?f.el=g.parentNode:b(g.parentNode,h)&&(f={el:g.parentNode,other:!0}))}return f.el&&!e.element.contains(f.el)&&(f.el=null),f},d=function(b,c,d){var e,g,h="UL"===c?"OL":"UL";d.selection.executeAndRestoreRangy(function(){if(e=f(h,d),e.length)for(var i=e.length;i--;)a.dom.renameElement(e[i],c.toLowerCase());else{g=f(["OL","UL"],d);for(var j=g.length;j--;)a.dom.resolveList(g[j],d.config.useLineBreaks);0===g.length&&a.dom.resolveList(b,d.config.useLineBreaks)}})},e=function(b,c,d){var e="UL"===c?"OL":"UL";d.selection.executeAndRestoreRangy(function(){for(var g=[b].concat(f(e,d)),h=g.length;h--;)a.dom.renameElement(g[h],c.toLowerCase())})},f=function(a,c){for(var d=c.selection.getOwnRanges(),e=[],f=d.length;f--;)e=e.concat(d[f].getNodes([1],function(c){return b(c,a)}));return e},g=function(b,c){var d,e,f=rangy.saveSelection(c.win),g="_wysihtml-temp-"+(new Date).getTime();c.commands.exec("formatBlock",{nodeName:"div",className:g});var h=c.element.querySelector("."+g);h.innerHTML=h.innerHTML.replace(a.INVISIBLE_SPACE_REG_EXP,""),h&&(d=/^(\s|(<br>))+$/i.test(h.innerHTML),e=a.dom.convertToList(h,b.toLowerCase(),c.parent.config.classNames.uneditableContainer),f&&rangy.restoreSelection(f),d&&c.selection.selectNode(e.querySelector("li"),!0))};return{exec:function(b,f,h){var i,j,k=b.doc,l="OL"===h?"insertOrderedList":"insertUnorderedList",m=b.selection.getSelection(),n=1===m.anchorNode.nodeType&&m.anchorNode.firstChild?m.anchorNode.childNodes[m.anchorOffset]:m.anchorNode,o=1===m.focusNode.nodeType&&m.focusNode.firstChild?m.focusNode.childNodes[m.focusOffset]||m.focusNode.lastChild:m.focusNode;m.isBackwards()&&(n=[o,o=n][0]),a.dom.domNode(o).is.emptyTextNode(!0)&&o&&(o=a.dom.domNode(o).prev({nodeTypes:[1,3],ignoreBlankTexts:!0})),a.dom.domNode(n).is.emptyTextNode(!0)&&n&&(n=a.dom.domNode(n).next({nodeTypes:[1,3],ignoreBlankTexts:!0})),i=n&&o?n===o?n:a.dom.domNode(n).commonAncestor(o,b.element):b.selection.getSelectedNode(),j=c(i,h,b),j.el?j.other?e(j.el,h,b):d(j.el,h,b):b.commands.support(l)?k.execCommand(l,!1,null):g(h,b)},state:function(a,b,d){var e=a.selection.getSelectedNode(),f=c(e,d,a);return f.el&&!f.other?f.el:!1}}}(wysihtml),function(a){a.commands.outdentList={exec:function(a,b,c){var d=a.selection.getSelectionParentsByTag("LI");return d?this.tryToPullLiLevel(d,a):!1},state:function(a,b){return!1},tryToPullLiLevel:function(b,c){var d,e,f,g,h,i=!1,j=this;return c.selection.executeAndRestoreRangy(function(){for(var k=b.length;k--;)if(g=b[k],g.parentNode&&(d=g.parentNode,"OL"===d.tagName||"UL"===d.tagName)){if(i=!0,e=a.dom.getParentElement(d.parentNode,{query:"ol, ul"},!1,c.element),f=a.dom.getParentElement(d.parentNode,{query:"li"},!1,c.element),e&&f)g.nextSibling&&(h=j.getAfterList(d,g),g.appendChild(h)),e.insertBefore(g,f.nextSibling);else{g.nextSibling&&(h=j.getAfterList(d,g),g.appendChild(h));for(var l=g.childNodes.length;l--;)d.parentNode.insertBefore(g.childNodes[l],d.nextSibling);d.parentNode.insertBefore(document.createElement("br"),d.nextSibling),g.parentNode.removeChild(g)}0===d.childNodes.length&&d.parentNode.removeChild(d)}}),i},getAfterList:function(a,b){for(var c=a.nodeName,d=document.createElement(c);b.nextSibling;)d.appendChild(b.nextSibling);return d}}}(wysihtml),function(a){a.commands.redo={exec:function(a){return a.undoManager.redo()},state:function(a){return!1}}}(wysihtml),function(a){var b={nodeName:"A"};a.commands.removeLink={exec:function(c,d){a.commands.formatInline.remove(c,d,b)},state:function(c,d){return a.commands.formatInline.state(c,d,b)}}}(wysihtml),function(a){a.commands.undo={exec:function(a){return a.undoManager.undo()},state:function(a){return!1}}}(wysihtml),function(a){var b=90,c=89,d=8,e=46,f=25,g="data-wysihtml-selection-node",h="data-wysihtml-selection-offset",i=('<span id="_wysihtml-undo" class="_wysihtml-temp">'+a.INVISIBLE_SPACE+"</span>",'<span id="_wysihtml-redo" class="_wysihtml-temp">'+a.INVISIBLE_SPACE+"</span>",a.dom);a.UndoManager=a.lang.Dispatcher.extend({constructor:function(a){this.editor=a,this.composer=a.composer,this.element=this.composer.element,this.position=0,this.historyStr=[],this.historyDom=[],this.transact(),this._observe()},_observe:function(){var a,f=this;this.composer.sandbox.getDocument();i.observe(this.element,"keydown",function(a){if(!a.altKey&&(a.ctrlKey||a.metaKey)){var d=a.keyCode,e=d===b&&!a.shiftKey,g=d===b&&a.shiftKey||d===c;e?(f.undo(),a.preventDefault()):g&&(f.redo(),a.preventDefault())}}),i.observe(this.element,"keydown",function(b){var c=b.keyCode;c!==a&&(a=c,(c===d||c===e)&&f.transact())}),this.editor.on("newword:composer",function(){f.transact()}).on("beforecommand:composer",function(){f.transact()})},transact:function(){var b,c,d,e,i,j=this.historyStr[this.position-1],k=this.composer.getValue(!1,!1),l=this.element.offsetWidth>0&&this.element.offsetHeight>0;if(k!==j){var m=this.historyStr.length=this.historyDom.length=this.position;m>f&&(this.historyStr.shift(),this.historyDom.shift(),this.position--),this.position++,l&&(b=this.composer.selection.getRange(),c=b&&b.startContainer?b.startContainer:this.element,d=b&&b.startOffset?b.startOffset:0,c.nodeType===a.ELEMENT_NODE?e=c:(e=c.parentNode,i=this.getChildNodeIndex(e,c)),e.setAttribute(h,d),"undefined"!=typeof i&&e.setAttribute(g,i));var n=this.element.cloneNode(!!k);this.historyDom.push(n),this.historyStr.push(k),e&&(e.removeAttribute(h),e.removeAttribute(g))}},undo:function(){this.transact(),this.undoPossible()&&(this.set(this.historyDom[--this.position-1]),this.editor.fire("undo:composer"))},redo:function(){this.redoPossible()&&(this.set(this.historyDom[++this.position-1]),this.editor.fire("redo:composer"))},undoPossible:function(){return this.position>1},redoPossible:function(){return this.position<this.historyStr.length},set:function(a){this.element.innerHTML="";for(var b=0,c=a.childNodes,d=a.childNodes.length;d>b;b++)this.element.appendChild(c[b].cloneNode(!0));var e,f,i;a.hasAttribute(h)?(e=a.getAttribute(h),i=a.getAttribute(g),f=this.element):(f=this.element.querySelector("["+h+"]")||this.element,e=f.getAttribute(h),i=f.getAttribute(g),f.removeAttribute(h),f.removeAttribute(g)),null!==i&&(f=this.getChildNodeByIndex(f,+i)),this.composer.selection.set(f,e)},getChildNodeIndex:function(a,b){for(var c=0,d=a.childNodes,e=d.length;e>c;c++)if(d[c]===b)return c},getChildNodeByIndex:function(a,b){return a.childNodes[b]}})}(wysihtml),wysihtml.views.View=Base.extend({constructor:function(a,b,c){this.parent=a,this.element=b,this.config=c,this.config.noTextarea||this._observeViewChange()},_observeViewChange:function(){var a=this;this.parent.on("beforeload",function(){a.parent.on("change_view",function(b){b===a.name?(a.parent.currentView=a,a.show(),setTimeout(function(){a.focus()},0)):a.hide()})})},focus:function(){if(!this.element||!this.element.ownerDocument||this.element.ownerDocument.querySelector(":focus")!==this.element)try{this.element&&this.element.focus()}catch(a){}},hide:function(){this.element.style.display="none"},show:function(){this.element.style.display=""},disable:function(){this.element.setAttribute("disabled","disabled")},enable:function(){this.element.removeAttribute("disabled")}}),function(a){var b=a.dom,c=a.browser;a.views.Composer=a.views.View.extend({name:"composer",constructor:function(a,b,c){this.base(a,b,c),this.config.noTextarea?this.editableArea=b:this.textarea=this.parent.textarea,this.config.contentEditableMode?this._initContentEditableArea():this._initSandbox()},clear:function(){this.element.innerHTML=c.displaysCaretInEmptyContentEditableCorrectly()?"":"<br>"},getValue:function(b,c){var d=this.isEmpty()?"":a.quirks.getCorrectInnerHTML(this.element);return b!==!1&&(d=this.parent.parse(d,c===!1?!1:!0)),d},setValue:function(a,b){b!==!1&&(a=this.parent.parse(a));try{this.element.innerHTML=a}catch(c){this.element.innerText=a}},cleanUp:function(a){var b;this.selection&&this.selection.isInThisEditable()&&(b=rangy.saveSelection(this.win)),this.parent.parse(this.element,void 0,a),b&&rangy.restoreSelection(b)},show:function(){this.editableArea.style.display=this._displayStyle||"",this.config.noTextarea||this.textarea.element.disabled||(this.disable(),this.enable())},hide:function(){this._displayStyle=b.getStyle("display").from(this.editableArea),"none"===this._displayStyle&&(this._displayStyle=null),this.editableArea.style.display="none"},disable:function(){this.parent.fire("disable:composer"),this.element.removeAttribute("contentEditable")},enable:function(){this.parent.fire("enable:composer"),this.element.setAttribute("contentEditable","true")},focus:function(b){a.browser.doesAsyncFocus()&&this.hasPlaceholderSet()&&this.clear(),this.base();var c=this.element.lastChild;b&&c&&this.selection&&("BR"===c.nodeName?this.selection.setBefore(this.element.lastChild):this.selection.setAfter(this.element.lastChild))},getScrollPos:function(){if(this.doc&&this.win){var a={};return"undefined"!=typeof this.win.pageYOffset?a.y=this.win.pageYOffset:a.y=(this.doc.documentElement||this.doc.body.parentNode||this.doc.body).scrollTop,"undefined"!=typeof this.win.pageXOffset?a.x=this.win.pageXOffset:a.x=(this.doc.documentElement||this.doc.body.parentNode||this.doc.body).scrollLeft,a}},setScrollPos:function(a){a&&"undefined"!=typeof a.x&&"undefined"!=typeof a.y&&this.win.scrollTo(a.x,a.y)},getTextContent:function(){return b.getTextContent(this.element)},hasPlaceholderSet:function(){return this.getTextContent()==(this.config.noTextarea?this.editableArea.getAttribute("data-placeholder"):this.textarea.element.getAttribute("placeholder"))&&this.placeholderSet},isEmpty:function(){var a=this.element.innerHTML.toLowerCase();return/^(\s|<br>|<\/br>|<p>|<\/p>)*$/i.test(a)||""===a||"<br>"===a||"<p></p>"===a||"<p><br></p>"===a||this.hasPlaceholderSet()},_initContentEditableArea:function(){var a=this;this.config.noTextarea?this.sandbox=new b.ContentEditableArea(function(){a._create()},{className:this.config.classNames.sandbox},this.editableArea):(this.sandbox=new b.ContentEditableArea(function(){a._create()},{className:this.config.classNames.sandbox}),this.editableArea=this.sandbox.getContentEditable(),b.insert(this.editableArea).after(this.textarea.element),this._createWysiwygFormField())},_initSandbox:function(){var a=this;this.sandbox=new b.Sandbox(function(){a._create()},{stylesheets:this.config.stylesheets,className:this.config.classNames.sandbox}),this.editableArea=this.sandbox.getIframe();var c=this.textarea.element;b.insert(this.editableArea).after(c),this._createWysiwygFormField()},_createWysiwygFormField:function(){if(this.textarea.element.form){var a=document.createElement("input");a.type="hidden",a.name="_wysihtml_mode",a.value=1,b.insert(a).after(this.textarea.element)}},_create:function(){var d=this;this.doc=this.sandbox.getDocument(),this.win=this.sandbox.getWindow(),this.element=this.config.contentEditableMode?this.sandbox.getContentEditable():this.doc.body,this.config.noTextarea?this.cleanUp():(this.textarea=this.parent.textarea,this.element.innerHTML=this.textarea.getValue(!0,!1)),this.selection=new a.Selection(this.parent,this.element,this.config.classNames.uneditableContainer),this.commands=new a.Commands(this.parent),this.config.noTextarea||b.copyAttributes(["className","spellcheck","title","lang","dir","accessKey"]).from(this.textarea.element).to(this.element),this._initAutoLinking(),b.addClass(this.element,this.config.classNames.composer),this.config.style&&!this.config.contentEditableMode&&this.style(),this.observe();var e=this.config.name;e&&(b.addClass(this.element,e),this.config.contentEditableMode||b.addClass(this.editableArea,e)),this.enable(),!this.config.noTextarea&&this.textarea.element.disabled&&this.disable();var f="string"==typeof this.config.placeholder?this.config.placeholder:this.config.noTextarea?this.editableArea.getAttribute("data-placeholder"):this.textarea.element.getAttribute("placeholder");f&&b.simulatePlaceholder(this.parent,this,f,this.config.classNames.placeholder),this.commands.exec("styleWithCSS",!1),this._initObjectResizing(),this._initUndoManager(),this._initLineBreaking(),this.config.noTextarea||!this.textarea.element.hasAttribute("autofocus")&&document.querySelector(":focus")!=this.textarea.element||c.isIos()||setTimeout(function(){d.focus(!0)},100),c.clearsContentEditableCorrectly()||a.quirks.ensureProperClearing(this),this.initSync&&this.config.sync&&this.initSync(),this.config.noTextarea||this.textarea.hide(),this.parent.fire("beforeload").fire("load")},_initAutoLinking:function(){var d=this,e=c.canDisableAutoLinking(),f=c.doesAutoLinkingInContentEditable();if(e&&this.commands.exec("AutoUrlDetect",!1,!1),this.config.autoLink){(!f||f&&e)&&(this.parent.on("newword:composer",function(){if(b.getTextContent(d.element).match(b.autoLink.URL_REG_EXP)){for(var c=d.selection.getSelectedNode(),e=d.element.querySelectorAll("."+d.config.classNames.uneditableContainer),f=!1,g=e.length;g--;)a.dom.contains(e[g],c)&&(f=!0);f||b.autoLink(c,[d.config.classNames.uneditableContainer])}}),b.observe(this.element,"blur",function(){b.autoLink(d.element,[d.config.classNames.uneditableContainer])}));var g=this.sandbox.getDocument().getElementsByTagName("a"),h=b.autoLink.URL_REG_EXP,i=function(c){var d=a.lang.string(b.getTextContent(c)).trim();return"www."===d.substr(0,4)&&(d="http://"+d),d};b.observe(this.element,"keydown",function(a){if(g.length){var c,e=d.selection.getSelectedNode(a.target.ownerDocument),f=b.getParentElement(e,{query:"a"},4);f&&(c=i(f),setTimeout(function(){var a=i(f);a!==c&&a.match(h)&&f.setAttribute("href",a)},0))}})}},_initObjectResizing:function(){if(this.commands.exec("enableObjectResizing",!0),c.supportsEvent("resizeend")){var d=["width","height"],e=d.length,f=this.element;b.observe(f,"resizeend",function(b){var c,g=b.target||b.srcElement,h=g.style,i=0;if("IMG"===g.nodeName){for(;e>i;i++)c=d[i],h[c]&&(g.setAttribute(c,parseInt(h[c],10)),h[c]="");a.quirks.redraw(f)}})}},_initUndoManager:function(){this.undoManager=new a.UndoManager(this.parent)},_initLineBreaking:function(){function d(a){var c=b.getParentElement(a,{query:"p, div"},2);c&&b.contains(e.element,c)&&e.selection.executeAndRestoreRangy(function(){e.config.useLineBreaks?((!c.firstChild||c.firstChild===c.lastChild&&1===c.firstChild.nodeType&&c.firstChild.classList.contains("rangySelectionBoundary"))&&c.appendChild(e.doc.createElement("br")),b.replaceWithChildNodes(c)):"P"!==c.nodeName&&b.renameElement(c,"p")})}var e=this,f="li, p, h1, h2, h3, h4, h5, h6",g="ul, ol, menu";this.config.useLineBreaks||b.observe(this.element,["focus","keydown"],function(){e.isEmpty()&&setTimeout(function(){var a=e.doc.createElement("P"),b=e.doc.createElement("span");b.className="text-font-normal",b.innerHTML+="<br>",e.element.innerHTML="",a.appendChild(b),e.element.appendChild(a),c.displaysCaretInEmptyContentEditableCorrectly()?e.selection.selectNode(a.firstChild,!0):e.selection.setBefore(a.firstChild.firstChild)},0)}),b.observe(this.element,"keydown",function(c){var h=c.keyCode;if(!(c.shiftKey||c.ctrlKey||c.defaultPrevented||h!==a.ENTER_KEY&&h!==a.BACKSPACE_KEY)){var i=b.getParentElement(e.selection.getSelectedNode(),{query:f},4);return i?void setTimeout(function(){var c,f=e.selection.getSelectedNode();if("LI"===i.nodeName){if(!f)return;c=b.getParentElement(f,{query:g},2),c||d(f)}h===a.ENTER_KEY&&i.nodeName.match(/^H[1-6]$/)&&d(f)},0):void(e.config.useLineBreaks&&h===a.ENTER_KEY&&!a.browser.insertsLineBreaksOnReturn()&&(c.preventDefault(),e.commands.exec("insertLineBreak")))}})}})}(wysihtml),function(a){var b=a.dom,c=document,d=window,e=c.createElement("div"),f=["background-color","color","cursor","font-family","font-size","font-style","font-variant","font-weight","line-height","letter-spacing","text-align","text-decoration","text-indent","text-rendering","word-break","word-wrap","word-spacing"],g=["background-color","border-collapse","border-bottom-color","border-bottom-style","border-bottom-width","border-left-color","border-left-style","border-left-width","border-right-color","border-right-style","border-right-width","border-top-color","border-top-style","border-top-width","clear","display","float","margin-bottom","margin-left","margin-right","margin-top","outline-color","outline-offset","outline-width","outline-style","padding-left","padding-right","padding-top","padding-bottom","position","top","left","right","bottom","z-index","vertical-align","text-align","-webkit-box-sizing","-moz-box-sizing","-ms-box-sizing","box-sizing","-webkit-box-shadow","-moz-box-shadow","-ms-box-shadow","box-shadow","-webkit-border-top-right-radius","-moz-border-radius-topright","border-top-right-radius","-webkit-border-bottom-right-radius","-moz-border-radius-bottomright","border-bottom-right-radius","-webkit-border-bottom-left-radius","-moz-border-radius-bottomleft","border-bottom-left-radius","-webkit-border-top-left-radius","-moz-border-radius-topleft","border-top-left-radius","width","height"],h=["html                 { height: 100%; }","body                 { height: 100%; padding: 1px 0 0 0; margin: -1px 0 0 0; }","body > p:first-child { margin-top: 0; }","._wysihtml-temp     { display: none; }",a.browser.isGecko?"body.placeholder { color: graytext !important; }":"body.placeholder { color: #a9a9a9 !important; }","img:-moz-broken      { -moz-force-broken-image-icon: 1; height: 24px; width: 24px; }"],i=function(a){if(a.setActive)try{a.setActive()}catch(e){}else{var f=a.style,g=c.documentElement.scrollTop||c.body.scrollTop,h=c.documentElement.scrollLeft||c.body.scrollLeft,i={position:f.position,top:f.top,left:f.left,WebkitUserSelect:f.WebkitUserSelect};b.setStyles({position:"absolute",top:"-99999px",left:"-99999px",WebkitUserSelect:"none"}).on(a),a.focus(),b.setStyles(i).on(a),d.scrollTo&&d.scrollTo(h,g)}};a.views.Composer.prototype.style=function(){var d,j=this,k=c.querySelector(":focus"),l=this.textarea.element,m=l.hasAttribute("placeholder"),n=m&&l.getAttribute("placeholder"),o=l.style.display,p=l.disabled;this.focusStylesHost=e.cloneNode(!1),this.blurStylesHost=e.cloneNode(!1),this.disabledStylesHost=e.cloneNode(!1),m&&l.removeAttribute("placeholder"),l===k&&l.blur(),l.disabled=!1,l.style.display=d="none",(l.getAttribute("rows")&&"auto"===b.getStyle("height").from(l)||l.getAttribute("cols")&&"auto"===b.getStyle("width").from(l))&&(l.style.display=d=o),b.copyStyles(g).from(l).to(this.editableArea).andTo(this.blurStylesHost),b.copyStyles(f).from(l).to(this.element).andTo(this.blurStylesHost),b.insertCSS(h).into(this.element.ownerDocument),l.disabled=!0,b.copyStyles(g).from(l).to(this.disabledStylesHost),b.copyStyles(f).from(l).to(this.disabledStylesHost),l.disabled=p,l.style.display=o,i(l),l.style.display=d,b.copyStyles(g).from(l).to(this.focusStylesHost),b.copyStyles(f).from(l).to(this.focusStylesHost),l.style.display=o,b.copyStyles(["display"]).from(l).to(this.editableArea);var q=a.lang.array(g).without(["display"]);return k?i(k):l.blur(),m&&l.setAttribute("placeholder",n),this.parent.on("focus:composer",function(){b.copyStyles(q).from(j.focusStylesHost).to(j.editableArea),b.copyStyles(f).from(j.focusStylesHost).to(j.element)}),this.parent.on("blur:composer",function(){b.copyStyles(q).from(j.blurStylesHost).to(j.editableArea),b.copyStyles(f).from(j.blurStylesHost).to(j.element)}),this.parent.observe("disable:composer",function(){b.copyStyles(q).from(j.disabledStylesHost).to(j.editableArea),b.copyStyles(f).from(j.disabledStylesHost).to(j.element)}),this.parent.observe("enable:composer",function(){b.copyStyles(q).from(j.blurStylesHost).to(j.editableArea),b.copyStyles(f).from(j.blurStylesHost).to(j.element)}),this}}(wysihtml),function(a){var b=a.dom,c=b.domNode,d=a.browser,e={66:"bold",73:"italic",80:"superscript",83:"subscript",85:"underline"},f={addListeners:function(a,b,c){for(var d=0,e=b.length;e>d;d++)a.addEventListener(b[d],c,!1)},removeListeners:function(a,b,c){for(var d=0,e=b.length;e>d;d++)a.removeEventListener(b[d],c,!1)},fixLastBrDeletionInTable:function(b,c){if(b.selection.caretIsInTheEndOfNode()){var d=b.selection.getSelection(),e=d.anchorNode;if(e&&1===e.nodeType&&(a.dom.getParentElement(e,{query:"td, th"},!1,b.element)||c)){var f=e.childNodes[d.anchorOffset];if(f&&1===f.nodeType&"BR"===f.nodeName)return f.parentNode.removeChild(f),!0}}return!1},handleUneditableDeletion:function(a){var b=a.selection.getBeforeSelection(!0);if(b&&("element"===b.type||"leafnode"===b.type)&&1===b.node.nodeType&&b.node.classList.contains(a.config.classNames.uneditableContainer)){if(f.fixLastBrDeletionInTable(a,!0))return!0;try{var c=new CustomEvent("wysihtml:uneditable:delete",{bubbles:!0,cancelable:!1});b.node.dispatchEvent(c)}catch(d){}return b.node.parentNode.removeChild(b.node),!0}return!1},fixDeleteInTheBeginningOfBlock:function(b){var d=b.selection,e=d.getPreviousNode();if(d.caretIsFirstInSelection(a.browser.usesControlRanges())&&e&&1===e.nodeType&&a.dom.domNode(e).is.block()&&!c(e).test({query:"ol, ul, table, tr, dl"})){if(/^\s*$/.test(e.textContent||e.innerText))return e.parentNode.removeChild(e),!0;if(e.lastChild){var f=e.lastChild,g=d.getSelectedNode(),h=c(e).commonAncestor(g,b.element),i=a.dom.getParentElement(g,{query:"h1, h2, h3, h4, h5, h6, p, pre, div, blockquote"},!1,h||b.element);if(i)return c(i).transferContentTo(e,!0),d.setAfter(f),!0;if(a.browser.usesControlRanges())return g=d.getCaretNode(),c(g).transferContentTo(e,!0),d.setAfter(f),!0}}return!1},fixDeleteInTheBeginningOfLi:function(b){if(a.browser.hasLiDeletingProblem()){var d,e,d,f,g=b.selection.getSelection(),h=g.anchorNode,i=b.selection.caretIsFirstInSelection();if(3===h.nodeType&&0===g.anchorOffset&&h===h.parentNode.firstChild&&(h=h.parentNode,i=!0),i&&h&&1===h.nodeType&&"LI"===h.nodeName&&(d=c(h).prev({nodeTypes:[1,3],ignoreBlankTexts:!0}),d||!h.parentNode||"UL"!==h.parentNode.nodeName&&"OL"!==h.parentNode.nodeName||(d=c(h.parentNode).prev({nodeTypes:[1,3],ignoreBlankTexts:!0}),f=h.parentNode),d))return e=h.firstChild,c(h).transferContentTo(d,!0),f&&0===f.children.length&&f.remove(),e?b.selection.setBefore(e):d&&(1===d.nodeType?d.lastChild?b.selection.setAfter(d.lastChild):b.selection.selectNode(d):b.selection.setAfter(d)),!0}return!1},fixDeleteInTheBeginningOfControlSelection:function(a){var b,d=a.selection,e=d.getPreviousNode(),f=d.getSelectedNode();return d.caretIsFirstInSelection()?(3===f.nodeType&&(f=f.parentNode),b=f.firstChild,c(f).transferContentTo(e,!0),b&&a.selection.setBefore(b),!0):!1},doLineBreaksModeEnterWithCaret:function(d){var e,f,g="p, pre, div, blockquote",h=!1;if(e=d.selection.getNodesNearCaret(),e&&((e.caretNode||e.nextNode)&&(f=b.getParentElement(e.caretNode||e.nextNode,{query:g},2),f===d.element&&(f=void 0)),f&&e.caretNode))if(c(e.caretNode).is.lineBreak()){if(d.config.doubleLineBreakEscapesBlock){h=!0,e.caretNode.parentNode.removeChild(e.caretNode),c(e.nextNode).is.lineBreak()&&e.nextNode.parentNode.removeChild(e.nextNode);var i=d.doc.createElement("br");c(e.nextNode).is.lineBreak()&&e.nextNode===f.lastChild?f.parentNode.insertBefore(i,f.nextSibling):d.selection.splitElementAtCaret(f,i),e.nextNode&&3===e.nextNode.nodeType&&(e.nextNode.data=e.nextNode.data.replace(/^ *[\r\n]+/,"")),d.selection.setBefore(i)}}else if(3===e.caretNode.nodeType&&a.browser.hasCaretBlockElementIssue()&&e.textOffset===e.caretNode.data.length&&!e.nextNode){h=!0;var j=d.doc.createElement("br"),k=d.doc.createElement("br"),l=d.doc.createDocumentFragment();l.appendChild(j),l.appendChild(k),d.selection.insertNode(l),d.selection.setBefore(k)}return h}},g=function(b,c){var d=c.selection;c.element;if(d.isCollapsed()){if(c.isEmpty()&&!c.config.useLineBreaks)return void b.preventDefault();if(f.handleUneditableDeletion(c))return void b.preventDefault();if(f.fixDeleteInTheBeginningOfLi(c))return void b.preventDefault();if(f.fixDeleteInTheBeginningOfBlock(c))return void b.preventDefault();if(f.fixLastBrDeletionInTable(c))return void b.preventDefault();if(a.browser.usesControlRanges()&&f.fixDeleteInTheBeginningOfControlSelection(c))return void b.preventDefault()}else d.containsUneditable()&&(b.preventDefault(),d.deleteContents())},h=function(a,b){if(b.config.useLineBreaks&&!a.shiftKey&&!a.ctrlKey){b.selection.isCollapsed()&&f.doLineBreaksModeEnterWithCaret(b)&&a.preventDefault()}if(d.hasCaretAtLinkEndInsertionProblems()&&b.selection.caretIsInTheEndOfNode()){var c=b.selection.getSelectedNode(!0),e=c&&3===c.nodeType?c.parentNode:c;e&&e.closest("a")&&3===c.nodeType&&c===e.lastChild&&b.selection.setAfter(e)}},i=function(a,b,c){if(a.selection.isCollapsed()){if(a.selection.caretIsInTheBeginnig("li"))if(c){if(a.commands.exec("outdentList"))return}else if(a.commands.exec("indentList"))return}else a.selection.deleteContents();a.commands.exec("insertHTML","&emsp;")},j=function(a){this.domNodeRemovedInterval&&clearInterval(domNodeRemovedInterval),this.parent.fire("destroy:composer")},k=function(a){this.parent.fire("beforeinteraction",a).fire("beforeinteraction:composer",a),setTimeout(function(){this.parent.fire("interaction",a).fire("interaction:composer",a)}.bind(this),0)},l=function(a){this.parent.fire("focus",a).fire("focus:composer",a),setTimeout(function(){this.focusState=this.getValue(!1,!1)}.bind(this),0)},m=function(a){if(this.focusState!==this.getValue(!1,!1)){var b=a;"function"==typeof Object.create&&(b=Object.create(a,{type:{value:"change"}})),this.parent.fire("change",b).fire("change:composer",b)}this.parent.fire("blur",a).fire("blur:composer",a)},n=function(a){this.parent.fire(a.type,a).fire(a.type+":composer",a),"paste"===a.type&&setTimeout(function(){this.parent.fire("newword:composer")}.bind(this),0)},o=function(b){this.config.copyedFromMarking&&(a.browser.supportsModernPaste()&&(b.clipboardData.setData("text/html",this.config.copyedFromMarking+this.selection.getHtml()),b.clipboardData.setData("text/plain",this.selection.getPlainText()),b.preventDefault()),this.parent.fire(b.type,b).fire(b.type+":composer",b))},p=function(b){var c=b.keyCode;(c===a.SPACE_KEY||c===a.ENTER_KEY)&&this.parent.fire("newword:composer"),c===a.BACKSPACE_KEY&&"txtEditor"===this.element.id&&a.commands.formatInline.cleanEditor(this)},q=function(b){if(!d.canSelectImagesInContentEditable()){var c=b.target,e=this.element.querySelectorAll("img"),f=this.element.querySelectorAll("."+this.config.classNames.uneditableContainer+" img"),g=a.lang.array(e).without(f);"IMG"===c.nodeName&&a.lang.array(g).contains(c)&&this.selection.selectNode(c)}a.browser.usesControlRanges()&&(this.selection.lastMouseDownPos={x:b.clientX,y:b.clientY},setTimeout(function(){delete this.selection.lastMouseDownPos}.bind(this),0))},r=function(a){var b=(a.target,this.selection.lastMouseDownPos);if(b){var c=document.body.createTextRange();setTimeout(function(){try{c.moveToPoint(b.x,b.y),c.select()}catch(a){}}.bind(this),0)}},s=function(b){if(this.config.classNames.uneditableContainer){var c=a.dom.getParentElement(b.target,{query:"."+this.config.classNames.uneditableContainer},!1,this.element);c&&this.selection.setAfter(c)}},t=function(a){d.canSelectImagesInContentEditable()||setTimeout(function(){this.selection.getSelection().removeAllRanges()}.bind(this),0)},u=function(b){var c,d=b.keyCode,f=e[d],j=this.selection.getSelectedNode(!0);j&&3===j.nodeType?j.parentNode:j;return!b.ctrlKey&&!b.metaKey||b.altKey||65!==d?((b.ctrlKey||b.metaKey)&&!b.altKey&&f&&(this.commands.exec(f),b.preventDefault()),d===a.DELETE_KEY?(b.preventDefault(),$("#delete_warning").show(),void setTimeout(function(){$("#delete_warning").hide()},5e3)):d===a.TAB_KEY?(b.preventDefault(),$("#tab_warning").show(),void setTimeout(function(){$("#tab_warning").hide()},5e3)):(d===a.BACKSPACE_KEY&&g(b,this),(d===a.BACKSPACE_KEY||d===a.DELETE_KEY)&&j&&"IMG"===j.nodeName&&(b.preventDefault(),c=j.parentNode,c.removeChild(j),"A"!==c.nodeName||c.firstChild||c.parentNode.removeChild(c),setTimeout(function(){a.quirks.redraw(this.element)}.bind(this),0)),this.config.handleTabKey&&d===a.TAB_KEY&&(b.preventDefault(),i(this,this.element,b.shiftKey)),void(d===a.ENTER_KEY&&h(b,this)))):(this.selection.selectAll(),
  void b.preventDefault())},v=function(b){if(0!==b.which&&this.selection.caretIsInTheEndOfNode()){var c,e,f=this.selection.getSelectedNode(!0),g=f&&3===f.nodeType?f.parentNode:f;g&&g.closest("a")&&f===g.lastChild&&(32!==b.which||this.selection.caretIsInTheEndOfNode(!0)&&d.hasCaretAtLinkEndInsertionProblems()?(c=this.doc.createTextNode(a.INVISIBLE_SPACE),this.selection.insertNode(c),this.selection.setBefore(c),setTimeout(function(){c.textContent.length>1?(c.textContent=c.textContent.replace(a.INVISIBLE_SPACE_REG_EXP,""),this.selection.setAfter(c)):c.remove()}.bind(this),0)):32===b.which&&3===f.nodeType&&/[\u00A0 ]$/.test(f.textContent)&&(f.textContent=f.textContent.replace(/[\u00A0 ]$/,""),e=this.doc.createTextNode(" "),g.parentNode.insertBefore(e,g.nextSibling),this.selection.setAfter(e,!1),b.preventDefault()))}};a.views.Composer.prototype.observeActions=f,a.views.Composer.prototype.observe=function(){var c=this.sandbox.getIframe?this.sandbox.getIframe():this.sandbox.getContentEditable(),e=(this.element,d.supportsEventsInIframeCorrectly()||this.sandbox.getContentEditable?this.element:this.sandbox.getWindow());this.focusState=this.getValue(!1,!1),this.actions=f,c.addEventListener(["DOMNodeRemoved"],j.bind(this),!1),d.supportsMutationEvents()||(this.domNodeRemovedInterval=setInterval(function(){b.contains(document.documentElement,c)||j.call(this)},250)),f.addListeners(e,["drop","paste","mouseup","focus","keyup","click"],k.bind(this)),e.addEventListener("focus",l.bind(this),!1),e.addEventListener("blur",m.bind(this),!1),f.addListeners(this.element,["drop","paste","beforepaste"],n.bind(this),!1),this.element.addEventListener("copy",o.bind(this),!1),this.element.addEventListener("mousedown",q.bind(this),!1),this.element.addEventListener("click",s.bind(this),!1),this.element.addEventListener("drop",t.bind(this),!1),this.element.addEventListener("keyup",p.bind(this),!1),this.element.addEventListener("keydown",u.bind(this),!1),this.element.addEventListener("keypress",v.bind(this),!1),a.browser.usesControlRanges()&&this.element.addEventListener("mscontrolselect",r.bind(this),!1),this.element.addEventListener("dragenter",function(){this.parent.fire("unset_placeholder")}.bind(this),!1)}}(wysihtml),function(a){var b=400;a.views.Synchronizer=Base.extend({constructor:function(a,b,c){this.editor=a,this.textarea=b,this.composer=c,this._observe()},fromComposerToTextarea:function(b){this.textarea.setValue(a.lang.string(this.composer.getValue(!1,!1)).trim(),b)},fromTextareaToComposer:function(a){var b=this.textarea.getValue(!1,!1);b?this.composer.setValue(b,a):(this.composer.clear(),this.editor.fire("set_placeholder"))},sync:function(a){"textarea"===this.editor.currentView.name?this.fromTextareaToComposer(a):this.fromComposerToTextarea(a)},_observe:function(){var c,d=this,e=this.textarea.element.form,f=function(){c=setInterval(function(){d.fromComposerToTextarea()},b)},g=function(){clearInterval(c),c=null};f(),e&&(a.dom.observe(e,"submit",function(){d.sync(!0)}),a.dom.observe(e,"reset",function(){setTimeout(function(){d.fromTextareaToComposer()},0)})),this.editor.on("change_view",function(a){"composer"!==a||c?"textarea"===a&&(d.fromComposerToTextarea(!0),g()):(d.fromTextareaToComposer(!0),f())}),this.editor.on("destroy:composer",g)}})}(wysihtml),function(a){a.views.SourceView=Base.extend({constructor:function(a,b){this.editor=a,this.composer=b,this._observe()},switchToTextarea:function(a){var b=this.composer.win.getComputedStyle(this.composer.element),c=parseFloat(b.width),d=Math.max(parseFloat(b.height),100);this.textarea||(this.textarea=this.composer.doc.createElement("textarea"),this.textarea.className="wysihtml-source-view"),this.textarea.style.width=c+"px",this.textarea.style.height=d+"px",this.textarea.value=this.editor.getValue(a,!0),this.composer.element.parentNode.insertBefore(this.textarea,this.composer.element),this.editor.currentView="source",this.composer.element.style.display="none"},switchToComposer:function(a){var b=this.textarea.value;b?this.composer.setValue(b,a):(this.composer.clear(),this.editor.fire("set_placeholder")),this.textarea.parentNode.removeChild(this.textarea),this.editor.currentView=this.composer,this.composer.element.style.display=""},_observe:function(){this.editor.on("change_view",function(a){"composer"===a?this.switchToComposer(!0):"textarea"===a&&this.switchToTextarea(!0)}.bind(this))}})}(wysihtml),wysihtml.views.Textarea=wysihtml.views.View.extend({name:"textarea",constructor:function(a,b,c){this.base(a,b,c),this._observe()},clear:function(){this.element.value=""},getValue:function(a){var b=this.isEmpty()?"":this.element.value;return a!==!1&&(b=this.parent.parse(b)),b},setValue:function(a,b){b!==!1&&(a=this.parent.parse(a)),this.element.value=a},cleanUp:function(a){var b=this.parent.parse(this.element.value,void 0,a);this.element.value=b},hasPlaceholderSet:function(){var a=wysihtml.browser.supportsPlaceholderAttributeOn(this.element),b=this.element.getAttribute("placeholder")||null,c=this.element.value,d=!c;return a&&d||c===b},isEmpty:function(){return!wysihtml.lang.string(this.element.value).trim()||this.hasPlaceholderSet()},_observe:function(){var a=this.element,b=this.parent,c={focusin:"focus",focusout:"blur"},d=wysihtml.browser.supportsEvent("focusin")?["focusin","focusout","change"]:["focus","blur","change"];b.on("beforeload",function(){wysihtml.dom.observe(a,d,function(a){var d=c[a.type]||a.type;b.fire(d).fire(d+":textarea")}),wysihtml.dom.observe(a,["paste","drop"],function(){setTimeout(function(){b.fire("paste").fire("paste:textarea")},0)})})}}),function(a){var b;a.Editor=a.lang.Dispatcher.extend({defaults:{name:b,style:!0,autoLink:!0,handleTabKey:!0,parserRules:{tags:{br:{},span:{},div:{},p:{},b:{},i:{},u:{}},classes:{}},pasteParserRulesets:null,parser:a.dom.parse,useLineBreaks:!0,doubleLineBreakEscapesBlock:!0,stylesheets:[],placeholderText:b,supportTouchDevices:!0,cleanUp:!0,contentEditableMode:!1,classNames:{composer:"wysihtml-editor",body:"wysihtml-supported",sandbox:"wysihtml-sandbox",placeholder:"wysihtml-placeholder",uneditableContainer:"wysihtml-uneditable-container"},copyedFromMarking:'<meta name="copied-from" content="wysihtml">'},constructor:function(b,c){if(this.editableElement="string"==typeof b?document.getElementById(b):b,this.config=a.lang.object({}).merge(this.defaults).merge(c).get(),this._isCompatible=a.browser.supported(),c&&c.classNames&&a.lang.object(this.config.classNames).merge(c.classNames),"textarea"!=this.editableElement.nodeName.toLowerCase()&&(this.config.contentEditableMode=!0,this.config.noTextarea=!0),this.config.noTextarea||(this.textarea=new a.views.Textarea(this,this.editableElement,this.config),this.currentView=this.textarea),!this._isCompatible||!this.config.supportTouchDevices&&a.browser.isTouchDevice()){var d=this;return void setTimeout(function(){d.fire("beforeload").fire("load")},0)}a.dom.addClass(document.body,this.config.classNames.body),this.composer=new a.views.Composer(this,this.editableElement,this.config),this.currentView=this.composer,"function"==typeof this.config.parser&&this._initParser(),this.on("beforeload",this.handleBeforeLoad)},handleBeforeLoad:function(){this.config.noTextarea?this.sourceView=new a.views.SourceView(this,this.composer):this.synchronizer=new a.views.Synchronizer(this,this.textarea,this.composer),this.runEditorExtenders()},runEditorExtenders:function(){a.editorExtenders.forEach(function(a){a(this)}.bind(this))},isCompatible:function(){return this._isCompatible},clear:function(){return this.currentView.clear(),this},getValue:function(a,b){return this.currentView.getValue(a,b)},setValue:function(a,b){return this.fire("unset_placeholder"),a?(this.currentView.setValue(a,b),this):this.clear()},cleanUp:function(a){this.currentView.cleanUp(a)},focus:function(a){return this.currentView.focus(a),this},disable:function(){return this.currentView.disable(),this},enable:function(){return this.currentView.enable(),this},isEmpty:function(){return this.currentView.isEmpty()},hasPlaceholderSet:function(){return this.currentView.hasPlaceholderSet()},destroy:function(){this.composer&&this.composer.sandbox&&this.composer.sandbox.destroy(),this.fire("destroy:composer"),this.off()},parse:function(b,c,d){var e=this.config.contentEditableMode?document:this.composer?this.composer.sandbox.getDocument():null,f=this.config.parser(b,{rules:d||this.config.parserRules,cleanUp:this.config.cleanUp,context:e,uneditableClass:this.config.classNames.uneditableContainer,clearInternals:c});return"object"==typeof b&&a.quirks.redraw(b),f},_initParser:function(){var b;a.browser.supportsModernPaste()?this.on("paste:composer",function(c){c.preventDefault(),b=a.dom.getPastedHtml(c),b&&this._cleanAndPaste(b)}.bind(this)):this.on("beforepaste:composer",function(b){b.preventDefault();var c=this.composer.getScrollPos();a.dom.getPastedHtmlWithDiv(this.composer,function(a){a&&this._cleanAndPaste(a),this.composer.setScrollPos(c)}.bind(this))}.bind(this))},_cleanAndPaste:function(b){function c(a){if(3!==a.nodeType){var b="P"===a.nodeName;if(b)for(brTags=a.getElementsByTagName("BR");brTags[0];)d(a,brTags[0]),brTags[0].parentNode.removeChild(brTags[0]);else{for(prevPNode=a.previousSibling;"P"!=prevPNode.nodeName;)prevPNode=prevPNode.previousSibling;for("BR"===a.nodeName?brTag=a:(brTags=a.getElementsByTagName("BR"),brTag=brTags[0]);brTag;){parent=prevPNode.parentNode;var c=prevPNode.ownerDocument,e=c.createRange();e.setStartAfter(prevPNode),e.setEndBefore(brTag);var f=c.createElement("p");e.surroundContents(f),brTag.parentNode.removeChild(brTag)}}}}function d(a,b){parent=a.parentNode;var c=e(parent,a),d=b.ownerDocument,f=d.createRange();f.setStart(parent,c),f.setEndBefore(b);var g=f.extractContents();parent.insertBefore(g,a)}function e(a,b){for(var c=a.childNodes.length;c--&&b!==a.childNodes[c];);return c}function f(a){cNodes=a.childNodes;var b;for(b=0;b<cNodes.length;b++)if("SPAN"!==cNodes[b].nodeName)return!0;return!1}var g=a.quirks.cleanPastedHTML(b,{referenceNode:this.composer.element,rules:this.config.pasteParserRulesets||[{set:this.config.parserRules}],uneditableClass:this.config.classNames.uneditableContainer}),h=this.composer.selection.getSelection(),i=h.anchorNode,j=h.anchorOffset;this.composer.selection.deleteContents(),this.composer.selection.insertHTML(g);var k=this.composer.selection.getBeforeSelection(!0).node,l=this.composer.doc.createElement("span");l.setAttribute("id","dummyNode"),null!==k.nextSibling?k.nextSibling.parentNode.insertBefore(l,k.nextSibling):k.parentNode.appendChild(l),this.composer.selection.setAfter(k);try{if(beginLimParent=i,"P"==beginLimParent.nodeName)parentPNode=beginLimParent;else if(3===beginLimParent.nodeType&&"P"==beginLimParent.parentNode.nodeName)parentPNode=beginLimParent.parentNode;else{for(;"P"!=beginLimParent.parentNode.nodeName;)beginLimParent=beginLimParent.parentNode;parentPNode=beginLimParent.parentNode,"P"!==i.parentNode.nodeName?cutoffNode=i.parentNode:cutoffNode=i;var m=document.getElementById("dummyNode");lastCopyNode=m.previousSibling,parent=beginLimParent.parentNode;var n=e(parent,beginLimParent),o=i.ownerDocument,p=o.createRange();p.setStart(parent,n),p.setEnd(i,j);var q=p.extractContents();parent.insertBefore(q,beginLimParent);var r;if(3!=beginLimParent.nodeType)for(;null!=cutoffNode.firstChild&&(child=cutoffNode.firstChild,parent.insertBefore(child,beginLimParent),child!=lastCopyNode););}if(pElements=parentPNode.getElementsByTagName("p"),numP=pElements.length,0==numP)c(parentPNode);else if(1==numP){C=pElements[0];for(var r;r=C.firstChild;)parentPNode.insertBefore(r,C);parentPNode.removeChild(C),c(parentPNode)}else{firstPNode=pElements[0],lastPNode=pElements[pElements.length-1],divParent=parentPNode.parentNode;var s=e(divParent,parentPNode),t=parentPNode.ownerDocument,u=t.createRange();u.setStart(divParent,s),u.setEndAfter(firstPNode);var v=u.extractContents();divParent.insertBefore(v,parentPNode),fPrevNode=parentPNode.previousSibling;for(var r=parentPNode.firstChild;r!=lastPNode;)divParent.insertBefore(r,parentPNode),r=parentPNode.firstChild;firstPToRemove=fPrevNode.getElementsByTagName("P");for(var r;r=firstPToRemove[0].firstChild;)fPrevNode.insertBefore(r,firstPToRemove[0]);fPrevNode.removeChild(firstPToRemove[0]),lastPToRemove=parentPNode.getElementsByTagName("P");for(var r;r=lastPToRemove[0].firstChild;)parentPNode.insertBefore(r,lastPToRemove[0]);parentPNode.removeChild(lastPToRemove[0]);for(var w,x=fPrevNode;null!==x&&x.previousSibling!=parentPNode;)w=x.nextSibling,c(x),x=w}}catch(y){}if("txtEditor"===this.composer.element.id){divElem=this.composer.element,childNodes=divElem.childNodes;var z;for(z=0;z<childNodes.length;z++)if("P"!==childNodes[z].nodeName){if("BR"===childNodes[z].nodeName){childNodes[z].parentNode.removeChild(childNodes[z]),z--;continue}newPNode=this.composer.doc.createElement("P"),innerNode=childNodes[z],newPNode.appendChild(innerNode),childNodes[z]?divElem.insertBefore(newPNode,childNodes[z]):divElem.appendChild(newPNode)}var A,B=this.composer.element.getElementsByTagName("P");for(A=0;A<B.length;A++){var C=B[A];0!=C.childNodes.length?f(C)&&(spNode=this.composer.doc.createElement("span"),spNode.className="text-font-normal",spNode.innerHTML=C.innerHTML,C.innerHTML="",C.appendChild(spNode)):(C.parentNode.removeChild(C),A--)}}var D,E=!1,F=this.composer.doc.getElementById("dummyNode");F.nextSibling?D=F.nextSibling:(D=F.parentNode,E=!0),F.parentNode.removeChild(F),E?(D.nextSibling||(newSpNode=this.composer.doc.createElement("span"),this.composer.element.appendChild(newSpNode)),this.composer.selection.setAfter(D)):this.composer.selection.setBefore(D),a.commands.formatInline.cleanEditor(this.composer)}})}(wysihtml),function(){function a(a,b){for(var c,d=[],e=0,f=a.length;f>e;e++)if(c=a[e].querySelectorAll(b))for(var g=c.length;g--;d.unshift(c[g]));return d}function b(a){a.parentNode.removeChild(a)}function d(a,b){a.parentNode.insertBefore(b,a.nextSibling)}function e(a,b){for(var c=a.nextSibling;1!=c.nodeType;)if(c=c.nextSibling,!b||b==c.tagName.toLowerCase())return c;return null}var f=wysihtml.dom,g=function(a){this.el=a,this.isColspan=!1,this.isRowspan=!1,this.firstCol=!0,this.lastCol=!0,this.firstRow=!0,this.lastRow=!0,this.isReal=!0,this.spanCollection=[],this.modified=!1},h=function(a,b){a?(this.cell=a,this.table=f.getParentElement(a,{query:"table"})):b&&(this.table=b,this.cell=this.table.querySelectorAll("th, td")[0])};h.prototype={addSpannedCellToMap:function(a,b,c,d,e,f){for(var h=[],i=c+(f?parseInt(f,10)-1:0),j=d+(e?parseInt(e,10)-1:0),k=c;i>=k;k++){"undefined"==typeof b[k]&&(b[k]=[]);for(var l=d;j>=l;l++)b[k][l]=new g(a),b[k][l].isColspan=e&&parseInt(e,10)>1,b[k][l].isRowspan=f&&parseInt(f,10)>1,b[k][l].firstCol=l==d,b[k][l].lastCol=l==j,b[k][l].firstRow=k==c,b[k][l].lastRow=k==i,b[k][l].isReal=l==d&&k==c,b[k][l].spanCollection=h,h.push(b[k][l])}},setCellAsModified:function(a){if(a.modified=!0,a.spanCollection.length>0)for(var b=0,c=a.spanCollection.length;c>b;b++)a.spanCollection[b].modified=!0},setTableMap:function(){var a,b,c,d,e,h,i,j,k=[],l=this.getTableRows();for(a=0;a<l.length;a++)for(b=l[a],c=this.getRowCells(b),h=0,"undefined"==typeof k[a]&&(k[a]=[]),d=0;d<c.length;d++){for(e=c[d];"undefined"!=typeof k[a][h];)h++;i=f.getAttribute(e,"colspan"),j=f.getAttribute(e,"rowspan"),i||j?(this.addSpannedCellToMap(e,k,a,h,i,j),h+=i?parseInt(i,10):1):(k[a][h]=new g(e),h++)}return this.map=k,k},getRowCells:function(b){var c=this.table.querySelectorAll("table"),d=c?a(c,"th, td"):[],e=b.querySelectorAll("th, td"),f=d.length>0?wysihtml.lang.array(e).without(d):e;return f},getTableRows:function(){var b=this.table.querySelectorAll("table"),c=b?a(b,"tr"):[],d=this.table.querySelectorAll("tr"),e=c.length>0?wysihtml.lang.array(d).without(c):d;return e},getMapIndex:function(a){for(var b=this.map.length,c=this.map&&this.map[0]?this.map[0].length:0,d=0;b>d;d++)for(var e=0;c>e;e++)if(this.map[d][e].el===a)return{row:d,col:e};return!1},getElementAtIndex:function(a){return this.setTableMap(),this.map[a.row]&&this.map[a.row][a.col]&&this.map[a.row][a.col].el?this.map[a.row][a.col].el:null},getMapElsTo:function(a){var b=[];if(this.setTableMap(),this.idx_start=this.getMapIndex(this.cell),this.idx_end=this.getMapIndex(a),this.idx_start.row>this.idx_end.row||this.idx_start.row==this.idx_end.row&&this.idx_start.col>this.idx_end.col){var c=this.idx_start;this.idx_start=this.idx_end,this.idx_end=c}if(this.idx_start.col>this.idx_end.col){var d=this.idx_start.col;this.idx_start.col=this.idx_end.col,this.idx_end.col=d}if(null!=this.idx_start&&null!=this.idx_end)for(var e=this.idx_start.row,f=this.idx_end.row;f>=e;e++)for(var g=this.idx_start.col,h=this.idx_end.col;h>=g;g++)b.push(this.map[e][g].el);return b},orderSelectionEnds:function(a){if(this.setTableMap(),this.idx_start=this.getMapIndex(this.cell),this.idx_end=this.getMapIndex(a),this.idx_start.row>this.idx_end.row||this.idx_start.row==this.idx_end.row&&this.idx_start.col>this.idx_end.col){var b=this.idx_start;this.idx_start=this.idx_end,this.idx_end=b}if(this.idx_start.col>this.idx_end.col){var c=this.idx_start.col;this.idx_start.col=this.idx_end.col,this.idx_end.col=c}return{start:this.map[this.idx_start.row][this.idx_start.col].el,end:this.map[this.idx_end.row][this.idx_end.col].el}},createCells:function(a,b,c){for(var d,e=this.table.ownerDocument,f=e.createDocumentFragment(),g=0;b>g;g++){if(d=e.createElement(a),c)for(var h in c)c.hasOwnProperty(h)&&d.setAttribute(h,c[h]);d.appendChild(document.createTextNode(" ")),f.appendChild(d)}return f},correctColIndexForUnreals:function(a,b){for(var c=this.map[b],d=-1,e=0;a>e;e++)c[e].isReal&&d++;return d},getLastNewCellOnRow:function(a,b){for(var c,d,e=this.getRowCells(a),f=0,g=e.length;g>f;f++)if(c=e[f],d=this.getMapIndex(c),d===!1||"undefined"!=typeof b&&d.row!=b)return c;return null},removeEmptyTable:function(){var a=this.table.querySelectorAll("td, th");return a&&0!=a.length?!1:(b(this.table),!0)},splitRowToCells:function(a){if(a.isColspan){var b=parseInt(f.getAttribute(a.el,"colspan")||1,10),c=a.el.tagName.toLowerCase();if(b>1){var e=this.createCells(c,b-1);d(a.el,e)}a.el.removeAttribute("colspan")}},getRealRowEl:function(a,b){var c=null,d=null;b=b||this.idx;for(var e=0,g=this.map[b.row].length;g>e;e++)if(d=this.map[b.row][e],d.isReal&&(c=f.getParentElement(d.el,{query:"tr"})))return c;return null===c&&a&&(c=f.getParentElement(this.map[b.row][b.col].el,{query:"tr"})||null),c},injectRowAt:function(a,b,c,e,g){var h=this.getRealRowEl(!1,{row:a,col:b}),i=this.createCells(e,c);if(h){var j=this.correctColIndexForUnreals(b,a);j>=0?d(this.getRowCells(h)[j],i):h.insertBefore(i,h.firstChild)}else{var k=this.table.ownerDocument.createElement("tr");k.appendChild(i),d(f.getParentElement(g.el,{query:"tr"}),k)}},canMerge:function(a){if(this.to=a,this.setTableMap(),this.idx_start=this.getMapIndex(this.cell),this.idx_end=this.getMapIndex(this.to),this.idx_start.row>this.idx_end.row||this.idx_start.row==this.idx_end.row&&this.idx_start.col>this.idx_end.col){var b=this.idx_start;this.idx_start=this.idx_end,this.idx_end=b}if(this.idx_start.col>this.idx_end.col){var c=this.idx_start.col;this.idx_start.col=this.idx_end.col,this.idx_end.col=c}for(var d=this.idx_start.row,e=this.idx_end.row;e>=d;d++)for(var f=this.idx_start.col,g=this.idx_end.col;g>=f;f++)if(this.map[d][f].isColspan||this.map[d][f].isRowspan)return!1;return!0},decreaseCellSpan:function(a,b){var c=parseInt(f.getAttribute(a.el,b),10)-1;c>=1?a.el.setAttribute(b,c):(a.el.removeAttribute(b),"colspan"==b&&(a.isColspan=!1),"rowspan"==b&&(a.isRowspan=!1),a.firstCol=!0,a.lastCol=!0,a.firstRow=!0,a.lastRow=!0,a.isReal=!0)},removeSurplusLines:function(){var a,c,d,e,g,h,i;if(this.setTableMap(),this.map){for(d=0,e=this.map.length;e>d;d++){for(a=this.map[d],i=!0,g=0,h=a.length;h>g;g++)if(c=a[g],!(f.getAttribute(c.el,"rowspan")&&parseInt(f.getAttribute(c.el,"rowspan"),10)>1&&c.firstRow!==!0)){i=!1;break}if(i)for(g=0;h>g;g++)this.decreaseCellSpan(a[g],"rowspan")}var j=this.getTableRows();for(d=0,e=j.length;e>d;d++)a=j[d],0==a.childNodes.length&&/^\s*$/.test(a.textContent||a.innerText)&&b(a)}},fillMissingCells:function(){var a=0,b=0,c=null;if(this.setTableMap(),this.map){a=this.map.length;for(var e=0;a>e;e++)this.map[e].length>b&&(b=this.map[e].length);for(var f=0;a>f;f++)for(var h=0;b>h;h++)this.map[f]&&!this.map[f][h]&&h>0&&(this.map[f][h]=new g(this.createCells("td",1)),c=this.map[f][h-1],c&&c.el&&c.el.parent&&d(this.map[f][h-1].el,this.map[f][h].el))}},rectify:function(){return this.removeEmptyTable()?!1:(this.removeSurplusLines(),this.fillMissingCells(),!0)},unmerge:function(){if(this.rectify()&&(this.setTableMap(),this.idx=this.getMapIndex(this.cell),this.idx)){var a=this.map[this.idx.row][this.idx.col],b=f.getAttribute(a.el,"colspan")?parseInt(f.getAttribute(a.el,"colspan"),10):1,c=a.el.tagName.toLowerCase();if(a.isRowspan){var d=parseInt(f.getAttribute(a.el,"rowspan"),10);if(d>1)for(var e=1,g=d-1;g>=e;e++)this.injectRowAt(this.idx.row+e,this.idx.col,b,c,a);a.el.removeAttribute("rowspan")}this.splitRowToCells(a)}},merge:function(a){if(this.rectify())if(this.canMerge(a)){for(var c=this.idx_end.row-this.idx_start.row+1,d=this.idx_end.col-this.idx_start.col+1,e=this.idx_start.row,f=this.idx_end.row;f>=e;e++)for(var g=this.idx_start.col,h=this.idx_end.col;h>=g;g++)e==this.idx_start.row&&g==this.idx_start.col?(c>1&&this.map[e][g].el.setAttribute("rowspan",c),d>1&&this.map[e][g].el.setAttribute("colspan",d)):(/^\s*<br\/?>\s*$/.test(this.map[e][g].el.innerHTML.toLowerCase())||(this.map[this.idx_start.row][this.idx_start.col].el.innerHTML+=" "+this.map[e][g].el.innerHTML),b(this.map[e][g].el));this.rectify()}else window.console&&console.log("Do not know how to merge allready merged cells.")},collapseCellToNextRow:function(a){var b=this.getMapIndex(a.el),c=b.row+1,e={row:c,col:b.col};if(c<this.map.length){var g=this.getRealRowEl(!1,e);if(null!==g){var h=this.correctColIndexForUnreals(e.col,e.row);if(h>=0)d(this.getRowCells(g)[h],a.el);else{var i=this.getLastNewCellOnRow(g,c);null!==i?d(i,a.el):g.insertBefore(a.el,g.firstChild)}parseInt(f.getAttribute(a.el,"rowspan"),10)>2?a.el.setAttribute("rowspan",parseInt(f.getAttribute(a.el,"rowspan"),10)-1):a.el.removeAttribute("rowspan")}}},removeRowCell:function(a){a.isReal?a.isRowspan?this.collapseCellToNextRow(a):b(a.el):parseInt(f.getAttribute(a.el,"rowspan"),10)>2?a.el.setAttribute("rowspan",parseInt(f.getAttribute(a.el,"rowspan"),10)-1):a.el.removeAttribute("rowspan")},getRowElementsByCell:function(){var a=[];if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),this.idx!==!1)for(var b=this.map[this.idx.row],c=0,d=b.length;d>c;c++)b[c].isReal&&a.push(b[c].el);return a},getColumnElementsByCell:function(){var a=[];if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),this.idx!==!1)for(var b=0,c=this.map.length;c>b;b++)this.map[b][this.idx.col]&&this.map[b][this.idx.col].isReal&&a.push(this.map[b][this.idx.col].el);return a},removeRow:function(){var a=f.getParentElement(this.cell,{query:"tr"});if(a){if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),this.idx!==!1)for(var c=this.map[this.idx.row],d=0,e=c.length;e>d;d++)c[d].modified||(this.setCellAsModified(c[d]),this.removeRowCell(c[d]));b(a)}},removeColCell:function(a){a.isColspan?parseInt(f.getAttribute(a.el,"colspan"),10)>2?a.el.setAttribute("colspan",parseInt(f.getAttribute(a.el,"colspan"),10)-1):a.el.removeAttribute("colspan"):a.isReal&&b(a.el)},removeColumn:function(){if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),this.idx!==!1)for(var a=0,b=this.map.length;b>a;a++)this.map[a][this.idx.col].modified||(this.setCellAsModified(this.map[a][this.idx.col]),this.removeColCell(this.map[a][this.idx.col]))},remove:function(a){if(this.rectify()){switch(a){case"row":this.removeRow();break;case"column":this.removeColumn()}this.rectify()}},addRow:function(a){var b=this.table.ownerDocument;if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),"below"==a&&f.getAttribute(this.cell,"rowspan")&&(this.idx.row=this.idx.row+parseInt(f.getAttribute(this.cell,"rowspan"),10)-1),this.idx!==!1){for(var c=this.map[this.idx.row],e=b.createElement("tr"),g=0,h=c.length;h>g;g++)c[g].modified||(this.setCellAsModified(c[g]),this.addRowCell(c[g],e,a));switch(a){case"below":d(this.getRealRowEl(!0),e);break;case"above":var i=f.getParentElement(this.map[this.idx.row][this.idx.col].el,{query:"tr"});i&&i.parentNode.insertBefore(e,i)}}},addRowCell:function(a,b,d){var e=a.isColspan?{colspan:f.getAttribute(a.el,"colspan")}:null;a.isReal?"above"!=d&&a.isRowspan?a.el.setAttribute("rowspan",parseInt(f.getAttribute(a.el,"rowspan"),10)+1):b.appendChild(this.createCells("td",1,e)):"above"!=d&&a.isRowspan&&a.lastRow?b.appendChild(this.createCells("td",1,e)):c.isRowspan&&a.el.attr("rowspan",parseInt(f.getAttribute(a.el,"rowspan"),10)+1)},add:function(a){this.rectify()&&(("below"==a||"above"==a)&&this.addRow(a),("before"==a||"after"==a)&&this.addColumn(a))},addColCell:function(a,b,c){var e,g=a.el.tagName.toLowerCase();switch(c){case"before":e=!a.isColspan||a.firstCol;break;case"after":e=!a.isColspan||a.lastCol||a.isColspan&&a.el==this.cell}if(e){switch(c){case"before":a.el.parentNode.insertBefore(this.createCells(g,1),a.el);break;case"after":d(a.el,this.createCells(g,1))}a.isRowspan&&this.handleCellAddWithRowspan(a,b+1,c)}else a.el.setAttribute("colspan",parseInt(f.getAttribute(a.el,"colspan"),10)+1)},addColumn:function(a){var b,c;if(this.setTableMap(),this.idx=this.getMapIndex(this.cell),"after"==a&&f.getAttribute(this.cell,"colspan")&&(this.idx.col=this.idx.col+parseInt(f.getAttribute(this.cell,"colspan"),10)-1),this.idx!==!1)for(var d=0,e=this.map.length;e>d;d++)b=this.map[d],b[this.idx.col]&&(c=b[this.idx.col],c.modified||(this.setCellAsModified(c),this.addColCell(c,d,a)))},handleCellAddWithRowspan:function(a,b,c){for(var g,h,i,j=parseInt(f.getAttribute(this.cell,"rowspan"),10)-1,k=f.getParentElement(a.el,{query:"tr"}),l=a.el.tagName.toLowerCase(),m=this.table.ownerDocument,n=0;j>n;n++)if(g=this.correctColIndexForUnreals(this.idx.col,b+n),k=e(k,"tr"))if(g>0)switch(c){case"before":h=this.getRowCells(k),g>0&&this.map[b+n][this.idx.col].el!=h[g]&&g==h.length-1?d(h[g],this.createCells(l,1)):h[g].parentNode.insertBefore(this.createCells(l,1),h[g]);break;case"after":d(this.getRowCells(k)[g],this.createCells(l,1))}else k.insertBefore(this.createCells(l,1),k.firstChild);else i=m.createElement("tr"),i.appendChild(this.createCells(l,1)),this.table.appendChild(i)}},f.table={getCellsBetween:function(a,b){var c=new h(a);return c.getMapElsTo(b)},addCells:function(a,b){var c=new h(a);c.add(b)},removeCells:function(a,b){var c=new h(a);c.remove(b)},mergeCellsBetween:function(a,b){var c=new h(a);c.merge(b)},unmergeCell:function(a){var b=new h(a);b.unmerge()},orderSelectionEnds:function(a,b){var c=new h(a);return c.orderSelectionEnds(b)},indexOf:function(a){var b=new h(a);return b.setTableMap(),b.getMapIndex(a)},findCell:function(a,b){var c=new h(null,a);return c.getElementAtIndex(b)},findRowByCell:function(a){var b=new h(a);return b.getRowElementsByCell()},findColumnByCell:function(a){var b=new h(a);return b.getColumnElementsByCell()},canMerge:function(a,b){var c=new h(a);return c.canMerge(b)}}}(),function(){var a=wysihtml.views.Composer.prototype.observe,b=function(){a.call(this),this.config.handleTables&&c.call(this)},c=function(){var a=function(){this.win.removeEventListener("load",a),this.doc.execCommand("enableObjectResizing",!1,"false"),this.doc.execCommand("enableInlineTableEditing",!1,"false")}.bind(this),b=function(){a.call(this),this.actions.removeListeners(this.sandbox.getIframe(),["focus","mouseup","mouseover"],b)}.bind(this);this.doc.execCommand&&wysihtml.browser.supportsCommand(this.doc,"enableObjectResizing")&&wysihtml.browser.supportsCommand(this.doc,"enableInlineTableEditing")&&(this.sandbox.getIframe?this.actions.addListeners(this.sandbox.getIframe(),["focus","mouseup","mouseover"],b):this.win.addEventListener("load",a)),this.tableSelection=wysihtml.quirks.tableCellsSelection(this.element,this.parent)},d=function(a,b){var c=function(){return a.addEventListener("mousedown",d),n},d=function(b){var c=wysihtml.dom.getParentElement(b.target,{query:"td, th"},!1,a);c&&e(c)},e=function(c){n.start=c,n.end=c,n.cells=[c],n.table=m.getParentElement(n.start,{query:"table"},!1,a),n.table&&(f(),m.addClass(c,o),a.addEventListener("mousemove",h),a.addEventListener("mouseup",i),b.fire("tableselectstart").fire("tableselectstart:composer"))},f=function(){if(a){var b=a.querySelectorAll("."+o);if(b.length>0)for(var c=0;c<b.length;c++)m.removeClass(b[c],o)}},g=function(a){for(var b=0;b<a.length;b++)m.addClass(a[b],o)},h=function(c){var d,e=null,h=m.getParentElement(c.target,{query:"td, th"},!1,a);h&&n.table&&n.start&&(e=m.getParentElement(h,{query:"table"},!1,a),e&&e===n.table&&(f(),d=n.end,n.end=h,n.cells=m.table.getCellsBetween(n.start,h),n.cells.length>1&&b.composer.selection.deselect(),g(n.cells),n.end!==d&&b.fire("tableselectchange").fire("tableselectchange:composer")))},i=function(c){a.removeEventListener("mousemove",h),a.removeEventListener("mouseup",i),b.fire("tableselect").fire("tableselect:composer"),setTimeout(function(){k()},0)},j=function(c){a.ownerDocument.removeEventListener("click",j),m.getParentElement(c.target,{query:"table"},!1,a)!=n.table&&(f(),n.table=null,n.start=null,n.end=null,b.fire("tableunselect").fire("tableunselect:composer"))},k=function(){a.ownerDocument.addEventListener("click",j)},l=function(c,d){n.start=c,n.end=d,n.table=m.getParentElement(n.start,{query:"table"},!1,a),selectedCells=m.table.getCellsBetween(n.start,n.end),g(selectedCells),k(),b.fire("tableselect").fire("tableselect:composer")},m=wysihtml.dom,n={table:null,start:null,end:null,cells:null,select:l},o="wysiwyg-tmp-selected-cell";return c()};wysihtml.Editor.prototype.defaults.handleTables=!0,wysihtml.quirks.tableCellsSelection=d,wysihtml.views.Composer.prototype.observe=b}(),function(a){var b=a.dom,c="wysihtml-command-dialog-opened",d="input, select, textarea",e="[data-wysihtml-dialog-field]",f="data-wysihtml-dialog-field";a.toolbar.Dialog=a.lang.Dispatcher.extend({constructor:function(a,b){this.link=a,this.container=b},_observe:function(){if(!this._observed){var d=this,e=function(a){var b=d._serialize();d.fire("save",b),d.hide(),a.preventDefault(),a.stopPropagation()};b.observe(d.link,"click",function(){b.hasClass(d.link,c)&&setTimeout(function(){d.hide()},0)}),b.observe(this.container,"keydown",function(b){var c=b.keyCode;c===a.ENTER_KEY&&e(b),c===a.ESCAPE_KEY&&d.cancel()}),b.delegate(this.container,"[data-wysihtml-dialog-action=save]","click",e),b.delegate(this.container,"[data-wysihtml-dialog-action=cancel]","click",function(a){d.cancel(),a.preventDefault(),a.stopPropagation()}),this._observed=!0}},_serialize:function(){for(var a={},b=this.container.querySelectorAll(e),c=b.length,d=0;c>d;d++)a[b[d].getAttribute(f)]=b[d].value;return a},_interpolate:function(a){for(var b,c,d,g=document.querySelector(":focus"),h=this.container.querySelectorAll(e),i=h.length,j=0;i>j;j++)b=h[j],b!==g&&(a&&"hidden"===b.type||(c=b.getAttribute(f),d=this.elementToChange&&"boolean"!=typeof this.elementToChange?this.elementToChange.getAttribute(c)||"":b.defaultValue,b.value=d))},update:function(a){this.elementToChange=a?a:this.elementToChange,this._interpolate()},show:function(a){var e=this.container.querySelector(d);if(this._observe(),this.update(a),b.addClass(this.link,c),this.container.style.display="",this.isOpen=!0,this.fire("show"),e&&!a)try{e.focus()}catch(f){}},_hide:function(a){this.elementToChange=null,b.removeClass(this.link,c),this.container.style.display="none",this.isOpen=!1},hide:function(){this._hide(),this.fire("hide")},cancel:function(){this._hide(),this.fire("cancel")}})}(wysihtml),function(a){var b=(a.dom,"[data-wysihtml-dialog-field]"),c="data-wysihtml-dialog-field";a.toolbar.Dialog_bgColorStyle=a.toolbar.Dialog.extend({multiselect:!0,_serialize:function(){for(var a={},d=this.container.querySelectorAll(b),e=d.length,f=0;e>f;f++)a[d[f].getAttribute(c)]=d[f].value;
  return a},_interpolate:function(d){for(var e,f=document.querySelector(":focus"),g=this.container.querySelectorAll(b),h=g.length,i=0,j=this.elementToChange?a.lang.object(this.elementToChange).isArray()?this.elementToChange[0]:this.elementToChange:null,k=j?j.getAttribute("style"):null,l=k?a.quirks.styleParser.parseColor(k,"background-color"):null;h>i;i++)e=g[i],e!==f&&(d&&"hidden"===e.type||"color"===e.getAttribute(c)&&(l?l[3]&&1!=l[3]?e.value="rgba("+l[0]+","+l[1]+","+l[2]+","+l[3]+");":e.value="rgb("+l[0]+","+l[1]+","+l[2]+");":e.value="rgb(0,0,0);"))}})}(wysihtml),function(a){a.toolbar.Dialog_createTable=a.toolbar.Dialog.extend({show:function(a){this.base(a)}})}(wysihtml),function(a){a.dom;a.toolbar.Dialog_fontSizeStyle=a.toolbar.Dialog.extend({multiselect:!0,_serialize:function(){return{size:this.container.querySelector('[data-wysihtml-dialog-field="size"]').value}},_interpolate:function(b){var c=document.querySelector(":focus"),d=this.container.querySelector("[data-wysihtml-dialog-field='size']"),e=this.elementToChange?a.lang.object(this.elementToChange).isArray()?this.elementToChange[0]:this.elementToChange:null,f=e?e.getAttribute("style"):null,g=f?a.quirks.styleParser.parseFontSize(f):null;d&&d!==c&&g&&!/^\s*$/.test(g)&&(d.value=g)}})}(wysihtml),function(a){var b="[data-wysihtml-dialog-field]",c="data-wysihtml-dialog-field";a.toolbar.Dialog_foreColorStyle=a.toolbar.Dialog.extend({multiselect:!0,_serialize:function(){for(var a={},d=this.container.querySelectorAll(b),e=d.length,f=0;e>f;f++)a[d[f].getAttribute(c)]=d[f].value;return a},_interpolate:function(d){for(var e,f,g=a.quirks.styleParser,h=document.querySelector(":focus"),i=this.container.querySelectorAll(b),j=i.length,k=0,l=this.elementToChange?a.lang.object(this.elementToChange).isArray()?this.elementToChange[0]:this.elementToChange:null,m=l?l.getAttribute("style"):null,n=m?g.parseColor(m,"color"):null;j>k;k++)e=i[k],e!==h&&(d&&"hidden"===e.type||"color"===e.getAttribute(c)&&(f=(e.dataset.colormode||"rgb").toLowerCase(),f="hex"===f?"hash":f,n?e.value=g.unparseColor(n,f):e.value=g.unparseColor([0,0,0],f)))}})}(wysihtml),function(a){function b(b,c){var d=b.commands.state(c.name,c.value);return!c.dialog.multiselect&&a.lang.object(d).isArray()&&(d=1===d.length?d[0]:!0),d}var c="wysihtml-command-disabled",d="wysihtml-commands-disabled",e="wysihtml-command-active",f="wysihtml-action-active",g=a.dom;a.toolbar.Toolbar=Base.extend({constructor:function(b,g,h){this.editor=b,this.container="string"==typeof g?document.getElementById(g):g,this.composer=b.composer,this._getLinks("command"),this._getLinks("action"),this._observe(),h&&this.show(),null!=b.config.classNameCommandDisabled&&(c=b.config.classNameCommandDisabled),null!=b.config.classNameCommandsDisabled&&(d=b.config.classNameCommandsDisabled),null!=b.config.classNameCommandActive&&(e=b.config.classNameCommandActive),null!=b.config.classNameActionActive&&(f=b.config.classNameActionActive);for(var i=this.container.querySelectorAll("[data-wysihtml-command=insertSpeech]"),j=i.length,k=0;j>k;k++)new a.toolbar.Speech(this,i[k])},_getLinks:function(b){for(var c,d,e,f,g,h,i=this[b+"Links"]=a.lang.array(this.container.querySelectorAll("[data-wysihtml-"+b+"]")).get(),j=i.length,k=0,l=this[b+"Mapping"]={};j>k;k++)c=i[k],e=c.getAttribute("data-wysihtml-"+b),f=c.getAttribute("data-wysihtml-"+b+"-value"),h=c.getAttribute("data-wysihtml-"+b+"-blank-value"),d=this.container.querySelector("[data-wysihtml-"+b+"-group='"+e+"']"),g=this._getDialog(c,e),l[e+":"+f]={link:c,group:d,name:e,value:f,tracksBlankValue:h,dialog:g,state:!1}},_getDialog:function(b,c){var d,e,f=this,g=this.container.querySelector("[data-wysihtml-dialog='"+c+"']");return g&&(d=a.toolbar["Dialog_"+c]?new a.toolbar["Dialog_"+c](b,g):new a.toolbar.Dialog(b,g),d.on("show",function(){e=f.composer.selection.getBookmark(),f.editor.fire("show:dialog",{command:c,dialogContainer:g,commandLink:b})}),d.on("save",function(a){e&&f.composer.selection.setBookmark(e),f._execCommand(c,a),f.editor.fire("save:dialog",{command:c,dialogContainer:g,commandLink:b}),f._hideAllDialogs(),f._preventInstantFocus(),e=void 0}),d.on("cancel",function(){e&&f.composer.selection.setBookmark(e),f.editor.fire("cancel:dialog",{command:c,dialogContainer:g,commandLink:b}),e=void 0,f._preventInstantFocus()}),d.on("hide",function(){f.editor.fire("hide:dialog",{command:c,dialogContainer:g,commandLink:b}),e=void 0})),d},execCommand:function(a,b){this.commandsDisabled||this._execCommand(a,b)},_execCommand:function(a,b){this.editor.focus(!1),this.composer.commands.exec(a,b),this._updateLinkStates()},execAction:function(a){var b=this.editor;"change_view"===a&&(b.currentView===b.textarea||"source"===b.currentView?b.fire("change_view","composer"):b.fire("change_view","textarea")),"showSource"==a&&b.fire("showSource")},_observe:function(){for(var c=this,e=this.editor,f=this.container,h=this.commandLinks.concat(this.actionLinks),i=h.length,j=0;i>j;j++)"A"===h[j].nodeName?g.setAttributes({href:"javascript:;",unselectable:"on"}).on(h[j]):g.setAttributes({unselectable:"on"}).on(h[j]);g.delegate(f,"[data-wysihtml-command], [data-wysihtml-action]","mousedown",function(a){a.preventDefault()}),g.delegate(f,"[data-wysihtml-command]","click",function(a){var d,e=this,f=e.getAttribute("data-wysihtml-command"),g=e.getAttribute("data-wysihtml-command-value"),h=c.commandMapping[f+":"+g];g||!h.dialog?c.execCommand(f,g):(d=b(c.composer,h),h.dialog.show(d)),a.preventDefault()}),g.delegate(f,"[data-wysihtml-action]","click",function(a){var b=this.getAttribute("data-wysihtml-action");c.execAction(b),a.preventDefault()}),e.on("interaction:composer",function(a){c.preventFocus||c._updateLinkStates()}),this._ownerDocumentClick=function(b){a.dom.contains(c.container,b.target)||a.dom.contains(c.composer.element,b.target)||(c._updateLinkStates(),c._preventInstantFocus())},this.container.ownerDocument.addEventListener("click",this._ownerDocumentClick,!1),this.editor.on("destroy:composer",this.destroy.bind(this)),this.editor.config.handleTables&&(e.on("tableselect:composer",function(){c.container.querySelectorAll('[data-wysihtml-hiddentools="table"]')[0].style.display=""}),e.on("tableunselect:composer",function(){c.container.querySelectorAll('[data-wysihtml-hiddentools="table"]')[0].style.display="none"})),e.on("change_view",function(a){setTimeout(function(){c.commandsDisabled="composer"!==a,c._updateLinkStates(),c.commandsDisabled?g.addClass(f,d):g.removeClass(f,d)},0)})},destroy:function(){this.container.ownerDocument.removeEventListener("click",this._ownerDocumentClick,!1)},_hideAllDialogs:function(){var a=this.commandMapping;for(var b in a)a[b].dialog&&a[b].dialog.hide()},_preventInstantFocus:function(){this.preventFocus=!0,setTimeout(function(){this.preventFocus=!1}.bind(this),0)},_updateLinkStates:function(){var a,d,h,i,j,k=this.commandMapping,l=this.composer,m=this.actionMapping;for(a in k)i=k[a],this.commandsDisabled?(d=!1,g.removeClass(i.link,e),i.group&&g.removeClass(i.group,e),i.dialog&&i.dialog.hide()):(d=this.composer.commands.state(i.name,i.value),g.removeClass(i.link,c),i.group&&g.removeClass(i.group,c)),(i.state!==d||i.tracksBlankValue)&&(i.state=d,d?i.tracksBlankValue?g.removeClass(i.link,e):(g.addClass(i.link,e),i.group&&g.addClass(i.group,e),!i.dialog||"undefined"!=typeof i.value&&null!==i.value||(d&&"object"==typeof d?(d=b(l,i),i.state=d,j=i.dialog.container.dataset?i.dialog.container.dataset.showdialogonselection:!1,l.config.showToolbarDialogsOnSelection||j?i.dialog.show(d):i.dialog.update(d)):i.dialog.hide())):i.tracksBlankValue?g.addClass(i.link,e):(g.removeClass(i.link,e),i.group&&g.removeClass(i.group,e),i.dialog&&!i.value&&i.dialog.hide()));for(a in m)h=m[a],"change_view"===h.name&&(h.state=this.editor.currentView===this.editor.textarea||"source"===this.editor.currentView,h.state?g.addClass(h.link,f):g.removeClass(h.link,f))},show:function(){this.container.style.display=""},hide:function(){this.container.style.display="none"}}),a.Editor.prototype.defaults.toolbar=void 0,a.Editor.prototype.defaults.showToolbarAfterInit=!0,a.Editor.prototype.defaults.showToolbarDialogsOnSelection=!0,a.extendEditor(function(b){b.config.toolbar&&(b.toolbar=new a.toolbar.Toolbar(b,b.config.toolbar,b.config.showToolbarAfterInit),b.on("destroy:composer",function(){b&&b.toolbar&&b.toolbar.destroy()}))})}(wysihtml),wysihtml.commands.alignCenterStyle=function(){var a={styleProperty:"textAlign",styleValue:"center",toggle:!0};return{exec:function(b,c){return wysihtml.commands.formatBlock.exec(b,"formatBlock",a)},state:function(b,c){return wysihtml.commands.formatBlock.state(b,"formatBlock",a)}}}(),wysihtml.commands.alignJustifyStyle=function(){var a={styleProperty:"textAlign",styleValue:"justify",toggle:!0};return{exec:function(b,c){return wysihtml.commands.formatBlock.exec(b,"formatBlock",a)},state:function(b,c){return wysihtml.commands.formatBlock.state(b,"formatBlock",a)}}}(),wysihtml.commands.alignLeftStyle=function(){var a={styleProperty:"textAlign",styleValue:"left",toggle:!0};return{exec:function(b,c){return wysihtml.commands.formatBlock.exec(b,"formatBlock",a)},state:function(b,c){return wysihtml.commands.formatBlock.state(b,"formatBlock",a)}}}(),wysihtml.commands.alignRightStyle=function(){var a={styleProperty:"textAlign",styleValue:"right",toggle:!0};return{exec:function(b,c){return wysihtml.commands.formatBlock.exec(b,"formatBlock",a)},state:function(b,c){return wysihtml.commands.formatBlock.state(b,"formatBlock",a)}}}(),wysihtml.commands.bgColorStyle=function(){return{exec:function(a,b,c){var d,e=wysihtml.quirks.styleParser.parseColor("background-color:"+(c.color||c),"background-color");e&&(d=(1===e[3]?"rgb("+[e[0],e[1],e[2]].join(", "):"rgba("+e.join(", "))+")",wysihtml.commands.formatInline.exec(a,b,{styleProperty:"backgroundColor",styleValue:d}))},state:function(a,b,c){var d,e=c?wysihtml.quirks.styleParser.parseColor("background-color:"+(c.color||c),"background-color"):null;return e&&(d=(1===e[3]?"rgb("+[e[0],e[1],e[2]].join(", "):"rgba("+e.join(", "))+")"),wysihtml.commands.formatInline.state(a,b,{styleProperty:"backgroundColor",styleValue:d})},remove:function(a,b){return wysihtml.commands.formatInline.remove(a,b,{styleProperty:"backgroundColor"})},stateValue:function(a,b,c){var d,e=this.state(a,b),f=!1;return e&&wysihtml.lang.object(e).isArray()&&(e=e[0]),e&&(d=e.getAttribute("style"))?(f=wysihtml.quirks.styleParser.parseColor(d,"background-color"),wysihtml.quirks.styleParser.unparseColor(f,c)):!1}}}(),wysihtml.commands.bold=function(){var a={nodeName:"B",toggle:!0};return{exec:function(b,c){wysihtml.commands.formatInline.exec(b,c,a),wysihtml.commands.formatInline.cleanEditor(b)},state:function(b,c){return wysihtml.commands.formatInline.state(b,c,a)}}}(),wysihtml.commands.formatCode=function(){return{exec:function(a,b,c){var d,e,f,g=this.state(a)[0];g?a.selection.executeAndRestore(function(){d=g.querySelector("code"),wysihtml.dom.replaceWithChildNodes(g),d&&wysihtml.dom.replaceWithChildNodes(d)}):(e=a.selection.getRange(),f=e.extractContents(),g=a.doc.createElement("pre"),d=a.doc.createElement("code"),c&&(d.className=c),g.appendChild(d),d.appendChild(f),e.insertNode(g),a.selection.selectNode(g))},state:function(a){var b,c=a.selection.getSelectedNode();return c&&c.nodeName&&"PRE"==c.nodeName&&c.firstChild&&c.firstChild.nodeName&&"CODE"==c.firstChild.nodeName?[c]:(b=wysihtml.dom.getParentElement(c,{query:"pre code"}),b?[b.parentNode]:!1)}}}(),wysihtml.commands.insertImage=function(){var a="IMG";return{exec:function(b,c,d){d="object"==typeof d?d:{src:d};var e,f,g=b.doc,h=this.state(b);if(h&&!d.src)return b.selection.setBefore(h),f=h.parentNode,f.removeChild(h),wysihtml.dom.removeEmptyTextNodes(f),"A"!==f.nodeName||f.firstChild||(b.selection.setAfter(f),f.parentNode.removeChild(f)),void wysihtml.quirks.redraw(b.element);if(h)for(var i in d)d.hasOwnProperty(i)&&h.setAttribute("className"===i?"class":i,d[i]);else{h=g.createElement(a);for(var j in d)h.setAttribute("className"===j?"class":j,d[j]);b.selection.insertNode(h),wysihtml.browser.hasProblemsSettingCaretAfterImg()?(e=g.createTextNode(wysihtml.INVISIBLE_SPACE),b.selection.insertNode(e),b.selection.setAfter(e)):b.selection.setAfter(h)}},state:function(b){var c,d,e,f=b.doc;return wysihtml.dom.hasElementWithTagName(f,a)&&(c=b.selection.getSelectedNode())?c.nodeName===a?c:c.nodeType!==wysihtml.ELEMENT_NODE?!1:(d=b.selection.getText(),(d=wysihtml.lang.string(d).trim())?!1:(e=b.selection.getNodes(wysihtml.ELEMENT_NODE,function(a){return"IMG"===a.nodeName}),1!==e.length?!1:e[0])):!1}}}(),wysihtml.commands.fontSize=function(){var a=/text-font-[0-9a-z\-]+/g;return{exec:function(b,c,d){wysihtml.commands.formatInline.exec(b,c,{className:"text-font-"+d,classRegExp:a,toggle:!0}),wysihtml.commands.formatInline.cleanEditor(b)},state:function(a,b,c){var d=wysihtml.commands.formatInline.state(a,b,{className:"text-font-"+c});return d&&$(".current-font").text(capitalise(d[0].className.replace("text-font-",""))),d}}}(),wysihtml.commands.fontSizeStyle=function(){return{exec:function(a,b,c){c=c.size||c,/^\s*$/.test(c)||wysihtml.commands.formatInline.exec(a,b,{styleProperty:"fontSize",styleValue:c,toggle:!1})},state:function(a,b,c){return wysihtml.commands.formatInline.state(a,b,{styleProperty:"fontSize",styleValue:c||void 0})},remove:function(a,b){return wysihtml.commands.formatInline.remove(a,b,{styleProperty:"fontSize"})},stateValue:function(a,b){var c,d=this.state(a,b);return d&&wysihtml.lang.object(d).isArray()&&(d=d[0]),d&&(c=d.getAttribute("style"))?wysihtml.quirks.styleParser.parseFontSize(c):!1}}}(),wysihtml.commands.foreColor=function(){var a=/wysiwyg-color-[0-9a-z]+/g;return{exec:function(b,c,d){wysihtml.commands.formatInline.exec(b,c,{className:"wysiwyg-color-"+d,classRegExp:a,toggle:!0})},state:function(a,b,c){return wysihtml.commands.formatInline.state(a,b,{className:"wysiwyg-color-"+c})}}}(),wysihtml.commands.foreColorStyle=function(){return{exec:function(a,b,c){var d,e;c&&(d=wysihtml.quirks.styleParser.parseColor("color:"+(c.color||c),"color"),d&&(e=(1===d[3]?"rgb("+[d[0],d[1],d[2]].join(", "):"rgba("+d.join(", "))+")",wysihtml.commands.formatInline.exec(a,b,{styleProperty:"color",styleValue:e})))},state:function(a,b,c){var d,e=c?wysihtml.quirks.styleParser.parseColor("color:"+(c.color||c),"color"):null;return e&&(d=(1===e[3]?"rgb("+[e[0],e[1],e[2]].join(", "):"rgba("+e.join(", "))+")"),wysihtml.commands.formatInline.state(a,b,{styleProperty:"color",styleValue:d})},remove:function(a,b){return wysihtml.commands.formatInline.remove(a,b,{styleProperty:"color"})},stateValue:function(a,b,c){var d,e=this.state(a,b),f=!1;return e&&wysihtml.lang.object(e).isArray()&&(e=e[0]),e&&(d=e.getAttribute("style"))?(f=wysihtml.quirks.styleParser.parseColor(d,"color"),wysihtml.quirks.styleParser.unparseColor(f,c)):!1}}}(),wysihtml.commands.insertBlockQuote=function(){var a={nodeName:"BLOCKQUOTE",toggle:!0};return{exec:function(b,c){return wysihtml.commands.formatBlock.exec(b,"formatBlock",a)},state:function(b,c){return wysihtml.commands.formatBlock.state(b,"formatBlock",a)}}}(),wysihtml.commands.insertHorizontalRule=function(){return{exec:function(a){var b=a.selection.getSelectedNode(),c=wysihtml.dom.getParentElement(b,{query:wysihtml.PERMITTED_PHRASING_CONTENT_ONLY},null,a.editableArea),d=document.createElement("hr");c?a.selection.splitElementAtCaret(c,d):a.selection.insertNode(d),d.nextSibling?a.selection.setBefore(d.nextSibling):a.selection.setAfter(d)},state:function(){return!1}}}(),wysihtml.commands.insertImage=function(){var a="IMG";return{exec:function(b,c,d){d="object"==typeof d?d:{src:d};var e,f,g=b.doc,h=this.state(b);if(h&&!d.src)return b.selection.setBefore(h),f=h.parentNode,f.removeChild(h),wysihtml.dom.removeEmptyTextNodes(f),"A"!==f.nodeName||f.firstChild||(b.selection.setAfter(f),f.parentNode.removeChild(f)),void wysihtml.quirks.redraw(b.element);if(h)for(var i in d)d.hasOwnProperty(i)&&h.setAttribute("className"===i?"class":i,d[i]);else{h=g.createElement(a);for(var j in d)h.setAttribute("className"===j?"class":j,d[j]);b.selection.insertNode(h),wysihtml.browser.hasProblemsSettingCaretAfterImg()?(e=g.createTextNode(wysihtml.INVISIBLE_SPACE),b.selection.insertNode(e),b.selection.setAfter(e)):b.selection.setAfter(h)}},state:function(b){var c,d,e,f=b.doc;return wysihtml.dom.hasElementWithTagName(f,a)&&(c=b.selection.getSelectedNode())?c.nodeName===a?c:c.nodeType!==wysihtml.ELEMENT_NODE?!1:(d=b.selection.getText(),(d=wysihtml.lang.string(d).trim())?!1:(e=b.selection.getNodes(wysihtml.ELEMENT_NODE,function(a){return"IMG"===a.nodeName}),1!==e.length?!1:e[0])):!1}}}(),wysihtml.commands.insertOrderedList=function(){return{exec:function(a,b){wysihtml.commands.insertList.exec(a,b,"OL")},state:function(a,b){return wysihtml.commands.insertList.state(a,b,"OL")}}}(),wysihtml.commands.insertUnorderedList=function(){return{exec:function(a,b){wysihtml.commands.insertList.exec(a,b,"UL")},state:function(a,b){return wysihtml.commands.insertList.state(a,b,"UL")}}}(),wysihtml.commands.italic=function(){var a={nodeName:"I",toggle:!0};return{exec:function(b,c){wysihtml.commands.formatInline.exec(b,c,a),wysihtml.commands.formatInline.cleanEditor(b)},state:function(b,c){return wysihtml.commands.formatInline.state(b,c,a)}}}(),wysihtml.commands.justifyCenter=function(){var a={className:"wysiwyg-text-align-center",classRegExp:/wysiwyg-text-align-[0-9a-z]+/g,toggle:!0};return{exec:function(b,c){return wysihtml.commands.formatBlock.exec(b,"formatBlock",a)},state:function(b,c){return wysihtml.commands.formatBlock.state(b,"formatBlock",a)}}}(),wysihtml.commands.justifyFull=function(){var a={className:"wysiwyg-text-align-justify",classRegExp:/wysiwyg-text-align-[0-9a-z]+/g,toggle:!0};return{exec:function(b,c){return wysihtml.commands.formatBlock.exec(b,"formatBlock",a)},state:function(b,c){return wysihtml.commands.formatBlock.state(b,"formatBlock",a)}}}(),wysihtml.commands.justifyLeft=function(){var a={className:"wysiwyg-text-align-left",classRegExp:/wysiwyg-text-align-[0-9a-z]+/g,toggle:!0};return{exec:function(b,c){return wysihtml.commands.formatBlock.exec(b,"formatBlock",a)},state:function(b,c){return wysihtml.commands.formatBlock.state(b,"formatBlock",a)}}}(),wysihtml.commands.justifyRight=function(){var a={className:"wysiwyg-text-align-right",classRegExp:/wysiwyg-text-align-[0-9a-z]+/g,toggle:!0};return{exec:function(b,c){return wysihtml.commands.formatBlock.exec(b,"formatBlock",a)},state:function(b,c){return wysihtml.commands.formatBlock.state(b,"formatBlock",a)}}}(),wysihtml.commands.subscript=function(){var a={nodeName:"SUB",toggle:!0};return{exec:function(b,c){wysihtml.commands.formatInline.exec(b,c,a),wysihtml.commands.formatInline.cleanEditor(b)},state:function(b,c){return wysihtml.commands.formatInline.state(b,c,a)}}}(),wysihtml.commands.superscript=function(){var a={nodeName:"SUP",toggle:!0};return{exec:function(b,c){wysihtml.commands.formatInline.exec(b,c,a),wysihtml.commands.formatInline.cleanEditor(b)},state:function(b,c){return wysihtml.commands.formatInline.state(b,c,a)}}}(),wysihtml.commands.addTableCells={exec:function(a,b,c){if(a.tableSelection&&a.tableSelection.start&&a.tableSelection.end){var d=wysihtml.dom.table.orderSelectionEnds(a.tableSelection.start,a.tableSelection.end);"before"==c||"above"==c?wysihtml.dom.table.addCells(d.start,c):("after"==c||"below"==c)&&wysihtml.dom.table.addCells(d.end,c),setTimeout(function(){a.tableSelection.select(d.start,d.end)},0)}},state:function(a,b){return!1}},wysihtml.commands.createTable={exec:function(a,b,c){var d,e,f;if(c&&c.cols&&c.rows&&parseInt(c.cols,10)>0&&parseInt(c.rows,10)>0){for(f=c.tableStyle?'<table style="'+c.tableStyle+'">':"<table>",f+="<tbody>",e=0;e<c.rows;e++){for(f+="<tr>",d=0;d<c.cols;d++)f+="<td><br></td>";f+="</tr>"}f+="</tbody></table>",a.commands.exec("insertHTML",f)}},state:function(a,b){return!1}},wysihtml.commands.deleteTableCells={exec:function(a,b,c){if(a.tableSelection&&a.tableSelection.start&&a.tableSelection.end){var d,e=wysihtml.dom.table.orderSelectionEnds(a.tableSelection.start,a.tableSelection.end),f=wysihtml.dom.table.indexOf(e.start),g=a.tableSelection.table;wysihtml.dom.table.removeCells(e.start,c),setTimeout(function(){d=wysihtml.dom.table.findCell(g,f),d||("row"==c&&(d=wysihtml.dom.table.findCell(g,{row:f.row-1,col:f.col})),"column"==c&&(d=wysihtml.dom.table.findCell(g,{row:f.row,col:f.col-1}))),d&&a.tableSelection.select(d,d)},0)}},state:function(a,b){return!1}},wysihtml.commands.mergeTableCells={exec:function(a,b){a.tableSelection&&a.tableSelection.start&&a.tableSelection.end&&(this.state(a,b)?wysihtml.dom.table.unmergeCell(a.tableSelection.start):wysihtml.dom.table.mergeCellsBetween(a.tableSelection.start,a.tableSelection.end))},state:function(a,b){if(a.tableSelection){var c=a.tableSelection.start,d=a.tableSelection.end;if(c&&d&&c==d&&(wysihtml.dom.getAttribute(c,"colspan")&&parseInt(wysihtml.dom.getAttribute(c,"colspan"),10)>1||wysihtml.dom.getAttribute(c,"rowspan")&&parseInt(wysihtml.dom.getAttribute(c,"rowspan"),10)>1))return[c]}return!1}},wysihtml.commands.underline=function(){var a={nodeName:"U",toggle:!0};return{exec:function(b,c){wysihtml.commands.formatInline.exec(b,c,a),wysihtml.commands.formatInline.cleanEditor(b)},state:function(b,c){return wysihtml.commands.formatInline.state(b,c,a)}}}();
  //# sourceMappingURL=wysihtml.min.map