text: !function(e,t){"use strict";function n(e,t,n){this.root=this.currentNode=e,this.nodeType=t,this.filter=n}function i(e,t,n){n=!!n;for(var i=n?t:t.parentNode;null!==i;){if(i===e)return!0;i=i.parentNode}return!1}function r(e,t){for(var n=e.length;n--;)if(!t(e[n]))return!1;return!0}function o(e,t,n){if(e.nodeName!==t)return!1;for(var i in n){var r=e.getAttribute(i),o=n[i];if(r&&(r=r.replace(/[;]$/,""),r=r.replace(/\s*:\s*/,":")),o&&(o=o.replace(/[;]$/,""),o=o.replace(/\s*:\s*/,":")),r!==o)return!1}return!0}function s(e,t){return!a(e)&&e.nodeType===t.nodeType&&e.nodeName===t.nodeName&&e.className===t.className&&(!e.style&&!t.style||e.style.cssText===t.style.cssText)}function a(e){return e.nodeType===x&&!!J[e.nodeName]}function d(e){return X.test(e.nodeName)}function l(e){var t=e.nodeType;return(t===x||t===A)&&!d(e)&&r(e.childNodes,d)}function h(e){var t=e.nodeType;return!(t!==x&&t!==A||d(e)||l(e))}function c(e,t){var i=new n(t._body,B,l,!1);return i.currentNode=e,i}function f(e,t){return c(e,t).previousNode()}function u(e,t){return c(e,t).nextNode()}function p(e){var t,n,i,r,o,s=e.parentNode;return s&&e.nodeType===x?(t=p(s),t+=(t?">":"")+e.nodeName,(n=e.id)&&(t+="#"+n),(i=e.className.trim())&&(r=i.split(/\s\s*/),r.sort(),t+=".",t+=r.join(".")),(o=e.dir)&&(t+="[dir="+o+"]")):t=s?p(s):"",t}function g(e){var t=e.nodeType;return t===x?e.childNodes.length:e.length||0}function m(e){var t=e.parentNode;return t&&t.removeChild(e),e}function v(e,t){var n=e.parentNode;n&&n.replaceChild(t,e)}function C(e){for(var t=e.ownerDocument.createDocumentFragment(),n=e.childNodes,i=n?n.length:0;i--;)t.appendChild(e.firstChild);return t}function _(e,n,i,r){var o,s,a,d,l=e.createElement(n);if(i instanceof Array&&(r=i,i=null),i)for(o in i)s=i[o],s!==t&&l.setAttribute(o,i[o]);if(r)for(a=0,d=r.length;d>a;a+=1)l.appendChild(r[a]);return l}function N(e,t){if(e.nodeType===x)for(var n,i,r,o=e.childNodes,a=o.length,l=[];a--;)if(n=o[a],i=a&&o[a-1],a&&d(n)&&s(n,i)&&!J[n.nodeName])t.startContainer===n&&(t.startContainer=i,t.startOffset+=g(i)),t.endContainer===n&&(t.endContainer=i,t.endOffset+=g(i)),t.startContainer===e&&(t.startOffset>a?t.startOffset-=1:t.startOffset===a&&(t.startContainer=i,t.startOffset=g(i))),t.endContainer===e&&(t.endOffset>a?t.endOffset-=1:t.endOffset===a&&(t.endContainer=i,t.endOffset=g(i))),m(n),n.nodeType===k?i.appendData(n.data):l.push(C(n));else if(n.nodeType===x){for(r=l.length;r--;)n.appendChild(l.pop());N(n,t)}}function S(e,t,n){for(var i,r,o,s=t;1===s.parentNode.childNodes.length;)s=s.parentNode;m(s),r=e.childNodes.length,i=e.lastChild,i&&"BR"===i.nodeName&&(e.removeChild(i),r-=1),o={startContainer:e,startOffset:r,endContainer:e,endOffset:r},e.appendChild(C(t)),N(e,o),n.setStart(o.startContainer,o.startOffset),n.collapse(!0),V&&(i=e.lastChild)&&"BR"===i.nodeName&&e.removeChild(i)}function y(e,t){var n,i;e||(e={});for(n in t)i=t[n],e[n]=i&&i.constructor===Object?y(e[n],i):i;return e}function b(e,t,n){var i,r=t.defaultView,o=e;this._win=r,this._doc=t,this._body=e,this._editorDiv=e,this._events={},this._lastSelection=null,G&&this.addEventListener("beforedeactivate",this.getSelection),this._hasZWS=!1,this._lastAnchorNode=null,this._lastFocusNode=null,this._path="",this._lastActiveNode=null,this.enabled=!0,this.addEventListener("keyup",this._updatePathOnEvent),this.addEventListener("mouseup",this._updatePathOnEvent),this._editorDiv.addEventListener("focus",this,!1),this._editorDiv.addEventListener("blur",this,!1),this.addEventListener("blur",this.getSelection),this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0,this._isInUndoState=!1,this._ignoreChange=!1,j?(i=new MutationObserver(this._docWasChanged.bind(this)),i.observe(o,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),this._mutation=i):this.addEventListener("keyup",this._keyUpDetectChange),this._awaitingPaste=!1,this.addEventListener(W?"beforecut":"cut",Be),this.addEventListener(W?"beforepaste":"paste",Oe),this.addEventListener(V?"keypress":"keydown",pe),this._keyHandlers=Object.create(Ce),this.setConfig(n),W&&(r.Text.prototype.splitText=function(e){var t=this.ownerDocument.createTextNode(this.data.slice(e)),n=this.nextSibling,i=this.parentNode,r=this.length-e;return n?i.insertBefore(t,n):i.appendChild(t),r&&this.deleteData(e,r),t}),this._editorDiv.setAttribute("contenteditable","true");try{t.execCommand("enableObjectResizing",!1,"false"),t.execCommand("enableInlineTableEditing",!1,"false")}catch(s){}this.setHTML("")}function T(e,t,n){var i,r;for(i=t.firstChild;i;i=r){if(r=i.nextSibling,d(i)){if(i.nodeType===k||"BR"===i.nodeName||"IMG"===i.nodeName){n.appendChild(i);continue}}else if(l(i)){n.appendChild(e.createDefaultBlock([T(e,i,e._doc.createDocumentFragment())]));continue}T(e,i,n)}return n}var E=2,x=1,k=3,A=11,B=1,O=4,R=0,L=1,D=2,I=3,U="​",P=e.defaultView,w=navigator.userAgent,F=/iP(?:ad|hone|od)/.test(w),H=/Mac OS X/.test(w),M=/Gecko\//.test(w),W=/Trident\/[456]\./.test(w),V=!!P.opera,q=/WebKit\//.test(w),K=H?"meta-":"ctrl-",z=W||V,Z=W||q,G=W,j="undefined"!=typeof MutationObserver,$=/[^ \t\r\n]/,Q=Array.prototype.indexOf;Object.create||(Object.create=function(e){var t=function(){};return t.prototype=e,new t});var Y={1:1,2:2,3:4,8:128,9:256,11:1024};n.prototype.nextNode=function(){for(var e,t=this.currentNode,n=this.root,i=this.nodeType,r=this.filter;;){for(e=t.firstChild;!e&&t&&t!==n;)e=t.nextSibling,e||(t=t.parentNode);if(!e)return null;if(Y[e.nodeType]&i&&r(e))return this.currentNode=e,e;t=e}},n.prototype.previousNode=function(){for(var e,t=this.currentNode,n=this.root,i=this.nodeType,r=this.filter;;){if(t===n)return null;if(e=t.previousSibling)for(;t=e.lastChild;)e=t;else e=t.parentNode;if(!e)return null;if(Y[e.nodeType]&i&&r(e))return this.currentNode=e,e;t=e}},n.prototype.previousPONode=function(){for(var e,t=this.currentNode,n=this.root,i=this.nodeType,r=this.filter;;){for(e=t.lastChild;!e&&t&&t!==n;)e=t.previousSibling,e||(t=t.parentNode);if(!e)return null;if(Y[e.nodeType]&i&&r(e))return this.currentNode=e,e;t=e}};var X=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|U|VAR|WBR)$/,J={BR:1,IMG:1,INPUT:1},ee=b.prototype;ee.getNearest=function(e,t,n){do{if(!i(this._body,e))return null;if(o(e,t,n))return e}while(e=e.parentNode);return null},ee.fixCursor=function(e){var t,n,i=e.ownerDocument,r=e;if(e===this._body&&((n=e.firstChild)&&"BR"!==n.nodeName||(t=this.createDefaultBlock(),n?e.replaceChild(t,n):e.appendChild(t),e=t,t=null)),d(e)){for(n=e.firstChild;Z&&n&&n.nodeType===k&&!n.data;)e.removeChild(n),n=e.firstChild;n||(Z?(t=i.createTextNode(U),this._didAddZWS()):t=i.createTextNode(""))}else if(z){for(;e.nodeType!==k&&!a(e);){if(n=e.firstChild,!n){t=i.createTextNode("");break}e=n}e.nodeType===k?/^ +$/.test(e.data)&&(e.data=""):a(e)&&e.parentNode.insertBefore(i.createTextNode(""),e)}else if(!e.querySelector("BR"))for(t=_(i,"BR");(n=e.lastElementChild)&&!d(n);)e=n;return t&&e.appendChild(t),r},ee.fixContainer=function(e){var t,n,i,r,o=e.childNodes,s=e.ownerDocument,a=null,l=this._config;for(t=0,n=o.length;n>t;t+=1)i=o[t],r="BR"===i.nodeName,!r&&d(i)?(a||(a=_(s,l.blockTag,l.blockAttributes)),a.appendChild(i),t-=1,n-=1):(r||a)&&(a||(a=_(s,l.blockTag,l.blockAttributes)),this.fixCursor(a),r?e.replaceChild(a,i):(e.insertBefore(a,i),t+=1,n+=1),a=null),h(i)&&this.fixContainer(i);return a&&e.appendChild(this.fixCursor(a)),e},ee.split=function(e,t,n){var i,r,o,s=e.nodeType;if(s===k&&e!==n)return this.split(e.parentNode,e.splitText(t),n);if(s===x){if("number"==typeof t&&(t=t<e.childNodes.length?e.childNodes[t]:null),e===n)return t;for(i=e.parentNode,r=e.cloneNode(!1);t;)o=t.nextSibling,r.appendChild(t),t=o;return"OL"===e.nodeName&&this.getNearest(e,"BLOCKQUOTE")&&(r.start=(+e.start||1)+e.childNodes.length-1),this.fixCursor(e),this.fixCursor(r),(o=e.nextSibling)?i.insertBefore(r,o):i.appendChild(r),this.split(i,r,n)}return t},ee.mergeContainers=function(e){var t,n,i=e.previousSibling,r=e.firstChild,o=e.ownerDocument,a="LI"===e.nodeName;if(!a||r&&/^[OU]L$/.test(r.nodeName))if(i&&s(i,e)){if(!h(i)){if(!a)return;n=_(o,"DIV"),n.appendChild(C(i)),i.appendChild(n)}m(e),t=!h(e),i.appendChild(C(e)),t&&this.fixContainer(i),r&&this.mergeContainers(r)}else a&&(i=_(o,"DIV"),e.insertBefore(i,r),this.fixCursor(i))};var te=function(e,t){for(var n=e.childNodes;t&&e.nodeType===x;)e=n[t-1],n=e.childNodes,t=n.length;return e},ne=function(e,t){if(e.nodeType===x){var n=e.childNodes;if(t<n.length)e=n[t];else{for(;e&&!e.nextSibling;)e=e.parentNode;e&&(e=e.nextSibling)}}return e},ie=function(e,t){var n,i,r,o,s=e.startContainer,a=e.startOffset,d=e.endContainer,l=e.endOffset;s.nodeType===k?(n=s.parentNode,i=n.childNodes,a===s.length?(a=Q.call(i,s)+1,e.collapsed&&(d=n,l=a)):(a&&(o=s.splitText(a),d===s?(l-=a,d=o):d===n&&(l+=1),s=o),a=Q.call(i,s)),s=n):i=s.childNodes,r=i.length,a===r?s.appendChild(t):s.insertBefore(t,i[a]),s===d&&(l+=i.length-r),e.setStart(s,a),e.setEnd(d,l)};ee.extractContentsOfRange=function(e,t){var n=e.startContainer,i=e.startOffset,r=e.endContainer,o=e.endOffset;t||(t=e.commonAncestorContainer),t.nodeType===k&&(t=t.parentNode);for(var s,a,d,l=this.split(r,o,t),h=this.split(n,i,t),c=t.ownerDocument.createDocumentFragment();h!==l;)s=h.nextSibling,c.appendChild(h),h=s;return n=t,i=l?Q.call(t.childNodes,l):t.childNodes.length,d=t.childNodes[i],a=d&&d.previousSibling,a&&a.nodeType===k&&d.nodeType===k&&(n=a,i=a.length,a.appendData(d.data),m(d)),e.setStart(n,i),e.collapse(!0),this.fixCursor(t),c},ee.deleteContentsOfRange=function(e){se(e);var t=e.startContainer,n=e.endContainer,i=(d(t)||l(t))&&(d(n)||l(n));this.extractContentsOfRange(e),oe(e),i&&(t=ae(e,this),n=de(e,this),t&&n&&t!==n&&S(t,n,e)),t&&this.fixCursor(t);var r=e.endContainer.ownerDocument.body,o=r.firstChild;o&&"BR"!==o.nodeName?e.collapse(!1):(this.fixCursor(r),e.selectNodeContents(r.firstChild))},ee.insertTreeFragmentIntoRange=function(e,t,n){for(var i=!0,r=t.childNodes,o=r.length;o--;)if(!d(r[o])){i=!1;break}if(e.collapsed||this.deleteContentsOfRange(e),oe(e),i)ie(e,t),e.collapse(!1);else{for(var s,a,c,p,g,m=e.startContainer,v=this.split(m,e.startOffset,this.getNearest(m.parentNode,"BLOCKQUOTE")||n),C=v.previousSibling,_=C,N=_.childNodes.length,S=v,y=0,b=v.parentNode;(s=_.lastChild)&&s.nodeType===x;){if("BR"===s.nodeName){N-=1;break}_=s,N=_.childNodes.length}for(;(s=S.firstChild)&&s.nodeType===x&&"BR"!==s.nodeName;)S=s;for(g=_.childNodes[N]||null;(s=t.firstChild)&&d(s);)_.insertBefore(s,g);for(;(s=t.lastChild)&&d(s);)S.insertBefore(s,S.firstChild),y+=1;for(a=t;a=u(a,this);)this.fixCursor(a);if(b.insertBefore(t,v),p=C.nextSibling,a=f(p,this),!/\S/.test(a.textContent))do b=a.parentNode,b.removeChild(a),a=b;while(b&&!b.lastChild&&b!==this._body);if(C.parentNode||(C=p.previousSibling),_.parentNode||(_=C||p.parentNode,N=C?C.childNodes.length:0),h(p)&&this.mergeContainers(p),c=v.previousSibling,a=l(v)?v:u(v,this),!/\S/.test(a.textContent))do b=a.parentNode,b.removeChild(a),a=b;while(b&&!b.lastChild&&b!==this._body);v.parentNode||(v=c.nextSibling),y||(S=c,y=c.childNodes.length),v&&h(v)&&this.mergeContainers(v),e.setStart(_,N),e.setEnd(S,y),oe(e)}};var re=function(e,t,n){var i=t.ownerDocument.createRange();if(i.selectNode(t),n){var r=e.compareBoundaryPoints(I,i)>-1,o=e.compareBoundaryPoints(L,i)<1;return!r&&!o}var s=e.compareBoundaryPoints(R,i)<1,a=e.compareBoundaryPoints(D,i)>-1;return s&&a},oe=function(e){for(var t,n=e.startContainer,i=e.startOffset,r=e.endContainer,o=e.endOffset;n.nodeType!==k&&(t=n.childNodes[i],t&&!a(t));)n=t,i=0;if(o)for(;r.nodeType!==k&&(t=r.childNodes[o-1],t&&!a(t));)r=t,o=g(r);else for(;r.nodeType!==k&&(t=r.firstChild,t&&!a(t));)r=t;e.collapsed?(e.setStart(r,o),e.setEnd(n,i)):(e.setStart(n,i),e.setEnd(r,o))},se=function(e,t){var n,i=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset;for(t||(t=e.commonAncestorContainer);i!==t&&!r;)n=i.parentNode,r=Q.call(n.childNodes,i),i=n;for(;o!==t&&s===g(o);)n=o.parentNode,s=Q.call(n.childNodes,o)+1,o=n;e.setStart(i,r),e.setEnd(o,s)},ae=function(e,t){var n,i=e.startContainer;return d(i)?n=f(i,t):l(i)?n=i:(n=te(i,e.startOffset),n=u(n,t)),n&&re(e,n,!0)?n:null},de=function(e,t){var n,i,r=e.endContainer;if(d(r))n=f(r,t);else if(l(r))n=r;else{if(n=ne(r,e.endOffset),!n)for(n=r.ownerDocument.body;i=n.lastChild;)n=i;n=f(n,t)}return n&&re(e,n,!0)?n:null},le=new n(null,O|B,function(e){return e.nodeType===k?$.test(e.data):"IMG"===e.nodeName}),he=function(e,t){var n=e.startContainer,i=e.startOffset;if(le.root=null,n.nodeType===k){if(i)return!1;le.currentNode=n}else le.currentNode=ne(n,i);return le.root=ae(e,t),!le.previousNode()},ce=function(e,t){var n,i=e.endContainer,r=e.endOffset;if(le.root=null,i.nodeType===k){if(n=i.data.length,n&&n>r)return!1;le.currentNode=i}else le.currentNode=te(i,r);return le.root=de(e,t),!le.nextNode()},fe=function(e,t){var n,i=ae(e,t),r=de(e,t);i&&r&&(n=i.parentNode,e.setStart(n,Q.call(n.childNodes,i)),n=r.parentNode,e.setEnd(n,Q.call(n.childNodes,r)+1))},ue={8:"backspace",9:"tab",13:"enter",32:"space",33:"pageup",34:"pagedown",37:"left",39:"right",46:"delete",219:"[",221:"]"},pe=function(e){if(this.enabled){var t=e.keyCode,n=ue[t],i="",r=this.getSelection();e.defaultPrevented||(n||(n=String.fromCharCode(t).toLowerCase(),/^[A-Za-z0-9]$/.test(n)||(n="")),V&&46===e.which&&(n="."),t>111&&124>t&&(n="f"+(t-111)),"backspace"!==n&&"delete"!==n&&(e.altKey&&(i+="alt-"),e.ctrlKey&&(i+="ctrl-"),e.metaKey&&(i+="meta-")),e.shiftKey&&(i+="shift-"),n=i+n,this._keyHandlers[n]?this._keyHandlers[n](this,e,r):1!==n.length||r.collapsed||(this._recordUndoState(r),this._getRangeAndRemoveBookmark(r),this.deleteContentsOfRange(r),this._ensureBottomLine(),this.setSelection(r),this._updatePath(r,!0)))}},ge=function(e){return function(t,n){n.preventDefault(),t[e]()}},me=function(e,t){return t=t||null,function(n,i){i.preventDefault();var r=n.getSelection();n.hasFormat(e,null,r)?n.changeFormat(null,{tag:e},r):n.changeFormat({tag:e},t,r)}},ve=function(e,t){try{t||(t=e.getSelection());var n,i=t.startContainer;for(i.nodeType===k&&(i=i.parentNode),n=i;d(n)&&(!n.textContent||n.textContent===U);)i=n,n=i.parentNode;i!==n&&(t.setStart(n,Q.call(n.childNodes,i)),t.collapse(!0),n.removeChild(i),l(n)||(n=f(n,e)),e.fixCursor(n),oe(t)),i===e._body&&(i=i.firstChild)&&"BR"===i.nodeName&&m(i),e._ensureBottomLine(),e.setSelection(t),e._updatePath(t,!0)}catch(r){e.didError(r)}},Ce={enter:function(e,t,n){var i,r,o;if(t.preventDefault(),e._recordUndoState(n),e._removeZWS(),e._getRangeAndRemoveBookmark(n),n.collapsed||e.deleteContentsOfRange(n),i=ae(n,e),!i||/^T[HD]$/.test(i.nodeName))return ie(n,e.createElement("BR")),n.collapse(!1),e.setSelection(n),void e._updatePath(n,!0);if((r=e.getNearest(i,"LI"))&&(i=r),!i.textContent){if(e.getNearest(i,"UL")||e.getNearest(i,"OL"))return e.modifyBlocks(ze,n);if(e.getNearest(i,"BLOCKQUOTE"))return e.modifyBlocks(He,n)}for(o=Pe(e,i,n.startContainer,n.startOffset),Le(i),xe(i),e.fixCursor(i);o.nodeType===x;){var s,a=o.firstChild;if("A"===o.nodeName&&(!o.textContent||o.textContent===U)){a=e._doc.createTextNode(""),v(o,a),o=a;break}for(;a&&a.nodeType===k&&!a.data&&(s=a.nextSibling,s&&"BR"!==s.nodeName);)m(a),a=s;if(!a||"BR"===a.nodeName||a.nodeType===k&&!V)break;o=a}n=e._createRange(o,0),e.setSelection(n),e._updatePath(n,!0)},backspace:function(e,t,n){if(e._removeZWS(),e._recordUndoState(n),e._getRangeAndRemoveBookmark(n),n.collapsed)if(he(n,e)){t.preventDefault();var r=ae(n,e),o=r&&f(r,e);if(o&&i(e._body,o)){if(!o.isContentEditable)return void m(o);for(S(o,r,n),r=o.parentNode;r&&!r.nextSibling;)r=r.parentNode;r&&(r=r.nextSibling)&&e.mergeContainers(r),e.setSelection(n)}else if(r){if(e.getNearest(r,"UL")||e.getNearest(r,"OL"))return e.modifyBlocks(ze,n);if(e.getNearest(r,"BLOCKQUOTE"))return e.modifyBlocks(Fe,n);e.setSelection(n),e._updatePath(n,!0)}}else e.setSelection(n),setTimeout(function(){ve(e)},0);else t.preventDefault(),e.deleteContentsOfRange(n),ve(e,n)},"delete":function(e,t,n){if(e._removeZWS(),e._recordUndoState(n),e._getRangeAndRemoveBookmark(n),n.collapsed)if(ce(n,e)){t.preventDefault();var r=ae(n,e),o=r&&u(r,e);if(o&&i(e._body,o,!0)){if(!o.isContentEditable)return void m(o);for(S(r,o,n),o=r.parentNode;o&&!o.nextSibling;)o=o.parentNode;o&&(o=o.nextSibling)&&e.mergeContainers(o),e.setSelection(n),e._updatePath(n,!0)}}else{var s,a,d,l=n.cloneRange();if(se(n,e._body),s=n.endContainer,a=n.endOffset,s.nodeType===x&&(d=s.childNodes[a],d&&"IMG"===d.nodeName))return t.preventDefault(),m(d),oe(n),void ve(e,n);e.setSelection(l),setTimeout(function(){ve(e)},0)}else t.preventDefault(),e.deleteContentsOfRange(n),ve(e,n)},tab:function(e,t,n){var i,r;if(e._removeZWS(),n.collapsed&&he(n,e))for(i=ae(n,e);r=i.parentNode;){if("UL"===r.nodeName||"OL"===r.nodeName){i.previousSibling&&(t.preventDefault(),t.stopPropagation(),e.modifyBlocks(Ke,n));break}i=r}},"shift-tab":function(e,t,n){if(e._removeZWS(),n.collapsed&&he(n,e)){var i=n.startContainer;(e.getNearest(i,"UL")||e.getNearest(i,"OL"))&&(t.preventDefault(),t.stopPropagation(),e.modifyBlocks(ze,n))}},space:function(e,t,n){var i,r;e._recordUndoState(n),e._getRangeAndRemoveBookmark(n),i=n.endContainer,r=i.parentNode,n.collapsed&&"A"===r.nodeName&&!i.nextSibling&&n.endOffset===g(i)&&n.setStartAfter(r),e.setSelection(n)},left:function(e){e._removeZWS()},right:function(e){e._removeZWS()}};H&&M&&P.getSelection().modify&&(Ce["meta-left"]=function(e,t){t.preventDefault(),e._sel.modify("move","backward","lineboundary")},Ce["meta-right"]=function(e,t){t.preventDefault(),e._sel.modify("move","forward","lineboundary")}),H||(Ce.pageup=function(e){e.moveCursorToStart()},Ce.pagedown=function(e){e.moveCursorToEnd()}),Ce[K+"b"]=me("B"),Ce[K+"i"]=me("I"),Ce[K+"u"]=me("U"),Ce[K+"shift-7"]=me("S"),Ce[K+"shift-8"]=ge("makeUnorderedList"),Ce[K+"shift-9"]=ge("makeOrderedList"),Ce[K+"y"]=ge("redo"),Ce[K+"z"]=ge("undo"),Ce[K+"shift-z"]=ge("redo");var _e={backgroundColor:{regexp:$,replace:function(e,t){return _(e,"SPAN",{"class":"rte-highlight",style:"background-color:"+t})}},color:{regexp:$,replace:function(e,t){return _(e,"SPAN",{"class":"rte-colour",style:"color:"+t})}}},Ne=function(e){return function(t,n){var i=_(t.ownerDocument,e);return n.replaceChild(i,t),i.appendChild(C(t)),i}},Se={SPAN:function(e,t){var n,i,r,o,s,a,d=e.style,l=e.ownerDocument;for(n in _e)i=_e[n],r=d[n],r&&i.regexp.test(r)&&(a=i.replace(l,r),o&&o.appendChild(a),o=a,s||(s=a));return s&&(o.appendChild(C(e)),t.replaceChild(s,e)),o||e},STRONG:Ne("B"),EM:Ne("I"),STRIKE:Ne("S"),FONT:function(e,t){var n,i,r,o=e.color,s=e.ownerDocument;return o&&/^#?([\dA-F]{3}){1,2}$/i.test(o)&&("#"!==o.charAt(0)&&(o="#"+o),n=_(s,"SPAN",{"class":"rte-colour",style:"color:"+o}),r||(r=n),i&&i.appendChild(n),i=n),r||(r=i=_(s,"SPAN")),t.replaceChild(r,e),i.appendChild(C(e)),i}},ye=/^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|UL)$/,be=/^(?:HEAD|META|STYLE)/,Te=new n(null,O|B,function(){return!0}),Ee=function je(e){var t,n,i,r,o,s,a,l,h,c,f,u,p=e.childNodes;for(t=e;d(t);)t=t.parentNode;for(Te.root=t,n=0,i=p.length;i>n;n+=1)if(r=p[n],o=r.nodeName,s=r.nodeType,a=Se[o],s===x){if(l=r.childNodes.length,a)r=a(r,e);else{if(be.test(o)){e.removeChild(r),n-=1,i-=1;continue}if(!ye.test(o)&&!d(r)){n-=1,i+=l-1,e.replaceChild(C(r),r);continue}}l&&je(r)}else{if(s===k){if(f=r.data,h=!$.test(f.charAt(0)),c=!$.test(f.charAt(f.length-1)),!h&&!c)continue;if(h){for(Te.currentNode=r;(u=Te.previousPONode())&&(o=u.nodeName,!("IMG"===o||"#text"===o&&/\S/.test(u.data)));)if(!d(u)){u=null;break}u||(f=f.replace(/^\s+/g,""))}if(c){for(Te.currentNode=r;(u=Te.nextNode())&&!("IMG"===o||"#text"===o&&/\S/.test(u.data));)if(!d(u)){u=null;break}u||(f=f.replace(/\s+$/g,""))}if(f){r.data=f;continue}}e.removeChild(r),n-=1,i-=1}return e},xe=function $e(e){for(var t,n=e.childNodes,i=n.length;i--;)t=n[i],t.nodeType!==x||a(t)?t.nodeType!==k||t.data||e.removeChild(t):($e(t),d(t)&&!t.firstChild&&e.removeChild(t))},ke=function(e){return e.nodeType===x?"BR"===e.nodeName:$.test(e.data)},Ae=function(e){for(var t,i=e.parentNode;d(i);)i=i.parentNode;return t=new n(i,B|O,ke),t.currentNode=e,!!t.nextNode()};ee.cleanupBRs=function(e){var t,n,i,r=e.querySelectorAll("BR"),o=[],s=r.length;for(t=0;s>t;t+=1)o[t]=Ae(r[t]);for(;s--;)n=r[s],i=n.parentNode,i&&(o[s]?d(i)||this.fixContainer(i):m(n))};var Be=function(){if(this.enabled){var e=this.getSelection(),t=this;this._recordUndoState(e),this._getRangeAndRemoveBookmark(e),this.setSelection(e),setTimeout(function(){try{t._ensureBottomLine()}catch(e){t.didError(e)}},0)}},Oe=function(e){if(this.enabled){var t,n,i,r,o=e.clipboardData,s=o&&o.items,a=!1,d=!1,l=null,h=this;if(s){for(e.preventDefault(),t=s.length;t--;){if(n=s[t],i=n.type,"text/html"===i)return void n.getAsString(function(e){if(e){var t="<!--StartFragment-->",n="<!--EndFragment-->",i=e.indexOf(t),r=e.lastIndexOf(n),o=e;i>-1&&r>-1&&(o=e.substring(i+t.length,r)),h.fireEvent("requestHtmlPaste",{rawHtml:o})}});"text/plain"===i&&(l=n),/^image\/.*/.test(i)&&(d=!0)}return void(d?(this.fireEvent("dragover",{dataTransfer:o,preventDefault:function(){a=!0}}),a&&this.fireEvent("drop",{dataTransfer:o})):l&&n.getAsString(function(e){h.insertPlainText(e,!0)}))}if(o&&(Q.call(o.types,"text/html")>-1||Q.call(o.types,"text/plain")>-1&&Q.call(o.types,"text/rtf")<0))return e.preventDefault(),void((r=o.getData("text/html"))?this.fireEvent("requestHtmlPaste",{rawHtml:r}):(r=o.getData("text/plain"))&&this.insertPlainText(r,!0));this._awaitingPaste=!0;var c=this._body,f=this.getSelection(),u=f.startContainer,p=f.startOffset,g=f.endContainer,v=f.endOffset,C=ae(f,this),_=this.createElement("DIV",{style:"position: absolute; overflow: hidden; top:"+(c.scrollTop+(C?C.getBoundingClientRect().top:0))+"px; right: 150%; width: 1px; height: 1px;"});c.appendChild(_),f.selectNodeContents(_),this.setSelection(f),setTimeout(function(){try{h._awaitingPaste=!1;for(var e,t,n="",i=_;_=i;)i=_.nextSibling,m(_),e=_.firstChild,e&&e===_.lastChild&&"DIV"===e.nodeName&&(_=e),n+=_.innerHTML;t=h._createRange(u,p,g,v),h.setSelection(t),n&&h.fireEvent("requestHtmlPaste",{rawHtml:n})}catch(r){h.didError(r)}},0)}};ee.setConfig=function(e){return e=y({blockTag:"DIV",blockAttributes:null,tagAttributes:{blockquote:null,ul:null,ol:null,li:null}},e),e.blockTag=e.blockTag.toUpperCase(),this._config=e,this},ee.setEnabled=function(e){if(e=!!e,this.enabled!==e){this.enabled=e;var t=this._body;e?t.setAttribute("contenteditable","true"):t.setAttribute("contenteditable","false")}},ee.createElement=function(e,t,n){return _(this._doc,e,t,n)},ee.createDefaultBlock=function(e){var t=this._config;return this.fixCursor(this.createElement(t.blockTag,t.blockAttributes,e))},ee.didError=function(e){console.log(e)},ee.getDocument=function(){return this._doc};var Re={focus:1,blur:1,pathChange:1,select:1,input:1,undoStateChange:1};ee.fireEvent=function(e,t){var n,i,r=this._events[e];if(r)for(t||(t={}),t.type!==e&&(t.type=e),r=r.slice(),n=r.length;n--;){i=r[n];try{i.handleEvent?i.handleEvent(t):i.call(this,t)}catch(o){o.details="Squire: fireEvent error. Event type: "+e,this.didError(o)}}return this},ee.destroy=function(){var e,t=this._doc,n=this._events;this._body.removeEventListener("focus",this,!1),this._body.removeEventListener("blur",this,!1);for(e in n)Re[e]||t.removeEventListener(e,this,!0);this._mutation&&this._mutation.disconnect()},ee.handleEvent=function(e){this.fireEvent(e.type,e)},ee.addEventListener=function(e,t){var n=this._events[e];return t?(n||(n=this._events[e]=[],Re[e]||this._body.addEventListener(e,this,!0)),n.push(t),this):(this.didError({name:"Squire: addEventListener with null or undefined fn",message:"Event type: "+e}),this)},ee.removeEventListener=function(e,t){var n,i=this._events[e];if(i){for(n=i.length;n--;)i[n]===t&&i.splice(n,1);i.length||(delete this._events[e],Re[e]||this._doc.removeEventListener(e,this,!1))}return this},ee._createRange=function(e,t,n,r){if(e instanceof this._win.Range)return e.cloneRange();var o=this._doc.createRange();return i(this._body,e,!0)||(e=this._body,t=0),o.setStart(e,t),n?(i(this._body,n,!0)||(n=this._body,r=this._body.childNodes.length),o.setEnd(n,r)):o.setEnd(e,t),o},ee.scrollRangeIntoView=function(e){},ee._moveCursorTo=function(e){var t=this._body,n=this._createRange(t,e?0:t.childNodes.length);return oe(n),this.setSelection(n),this},ee.moveCursorToStart=function(){return this._moveCursorTo(!0)},ee.moveCursorToEnd=function(){return this._moveCursorTo(!1)},ee._ensureRangeWithin=function(e){if(!e)return e;var t=e.startContainer,n=e.endContainer;return i(this._body,t,!0)||i(this._body,n,!0)?(i(this._body,t,!0)||e.setStart(this._body,0),i(this._body,n,!0)||e.setEnd(this._body,this._body.childNodes.length),e):(e.setStart(this._body,0),e.setEnd(this._body,0),e)},ee.setSelection=function(e){if(e){e=this._ensureRangeWithin(e),F&&this._body.focus();var t=this._getWindowSelection();t&&(t.removeAllRanges(),t.addRange(e),this.scrollRangeIntoView(e))}return this},ee._isSelectionWithinEditor=function(e){if(!e)return!1;var t=e.startContainer,n=e.endContainer;return i(this._body,t,!0)&&i(this._body,n,!0)},ee._getWindowSelection=function(){return this._win.getSelection()||null},ee.getSelection=function(){var e,t,n,i=this._getWindowSelection();return i&&i.rangeCount?(e=i.getRangeAt(0).cloneRange(),t=e.startContainer,n=e.endContainer,t&&a(t)&&e.setStartBefore(t),n&&a(n)&&e.setEndBefore(n),this._isSelectionWithinEditor(e)?this._lastSelection=e:e=this._lastSelection&&this._isSelectionWithinEditor(this._lastSelection)?this._lastSelection:null):this._isSelectionWithinEditor(this._lastSelection)&&(e=this._lastSelection),e?e.collapsed&&e.startContainer===this._body&&e.endContainer===this._body&&(this._body.childNodes&&0!==this._body.childNodes.length||this.fixCursor(this._body),e=this._createRange(this._body.firstChild,0)):(this._body.childNodes&&0!==this._body.childNodes.length||this.fixCursor(this._body),e=this._createRange(this._body.firstChild,0)),e},ee.getSelectedText=function(){var e,t=this.getSelection(),i=new n(t.commonAncestorContainer,O|B,function(e){return re(t,e,!0)}),r=t.startContainer,o=t.endContainer,s=i.currentNode=r,a="",l=!1;for(i.filter(s)||(s=i.nextNode());s;)s.nodeType===k?(e=s.data,e&&/\S/.test(e)&&(s===o&&(e=e.slice(0,t.endOffset)),s===r&&(e=e.slice(t.startOffset)),a+=e,l=!0)):("BR"===s.nodeName||l&&!d(s))&&(a+="\n",l=!1),s=i.nextNode();return a},ee.getPath=function(){return this._path};var Le=function(e){for(var t,i,r,o=new n(e,O,function(){return!0},!1);i=o.nextNode();)for(;(r=i.data.indexOf(U))>-1;){if(1===i.length){do t=i.parentNode,t.removeChild(i),i=t,o.currentNode=t;while(d(i)&&!g(i));break}i.deleteData(r,1)}};ee._didAddZWS=function(){this._hasZWS=!0},ee._removeZWS=function(){this._hasZWS&&(Le(this._body),this._hasZWS=!1)},ee._updatePath=function(e,t){var n,i=e.startContainer,r=e.endContainer;(t||i!==this._lastAnchorNode||r!==this._lastFocusNode)&&(this._lastAnchorNode=i,this._lastFocusNode=r,n=i&&r?i===r?p(r):"(selection)":"",this._path!==n&&(this._path=n,this.fireEvent("pathChange",{path:n}))),e.collapsed||this.fireEvent("select"),i===r&&e.collapsed?r!==this._lastActiveNode&&(this._lastActiveNode=r,this.fireEvent("activeNodeChange",{})):this._lastActiveNode=null},ee._updatePathOnEvent=function(){this._updatePath(this.getSelection())},ee.focus=function(){return V||this._body.focus(),this._body.focus(),this},ee.blur=function(){return M&&this._body.blur(),this._body.blur(),this};var De="squire-selection-start",Ie="squire-selection-end";ee._saveRangeToBookmark=function(e){var t,n=this.createElement("INPUT",{id:De,type:"hidden"}),i=this.createElement("INPUT",{id:Ie,type:"hidden"});ie(e,n),e.collapse(!1),ie(e,i),n.compareDocumentPosition(i)&E&&(n.id=Ie,i.id=De,t=n,n=i,i=t),e.setStartAfter(n),e.setEndBefore(i)},ee._getRangeAndRemoveBookmark=function(e){var t=this._doc,n=t.getElementById(De),i=t.getElementById(Ie);if(n&&i){var r,o=n.parentNode,s=i.parentNode,a={startContainer:o,endContainer:s,startOffset:Q.call(o.childNodes,n),endOffset:Q.call(s.childNodes,i)};o===s&&(a.endOffset-=1),m(n),m(i),N(o,a),o!==s&&N(s,a),e||(e=t.createRange()),e.setStart(a.startContainer,a.startOffset),e.setEnd(a.endContainer,a.endOffset),r=e.collapsed,oe(e),r&&e.collapse(!0)}return e||null},ee._keyUpDetectChange=function(e){var t=e.keyCode;e.ctrlKey||e.metaKey||e.altKey||!(16>t||t>20)||!(33>t||t>45)||this._docWasChanged()},ee._docWasChanged=function(){return j&&this._ignoreChange?void(this._ignoreChange=!1):(this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),void this.fireEvent("input"))},ee._recordUndoState=function(e){if(!this._isInUndoState){var t=this._undoIndex+=1,n=this._undoStack;t<this._undoStackLength&&(n.length=this._undoStackLength=t),e&&this._saveRangeToBookmark(e),n[t]=this._getHTML(!1),this._undoStackLength+=1,this._isInUndoState=!0}},ee.undo=function(){if(0!==this._undoIndex||!this._isInUndoState){this._recordUndoState(this.getSelection()),this._undoIndex-=1,this._setHTML(this._undoStack[this._undoIndex]);var e=this._getRangeAndRemoveBookmark();e&&this.setSelection(e),this._isInUndoState=!0,this.fireEvent("undoStateChange",{canUndo:0!==this._undoIndex,canRedo:!0}),this.fireEvent("input")}return this},ee.redo=function(){var e=this._undoIndex,t=this._undoStackLength;if(t>e+1&&this._isInUndoState){this._undoIndex+=1,this._setHTML(this._undoStack[this._undoIndex]);var n=this._getRangeAndRemoveBookmark();n&&this.setSelection(n),this.fireEvent("undoStateChange",{canUndo:!0,canRedo:t>e+2}),this.fireEvent("input")}return this},ee.hasFormat=function(e,t,i){if(e=e.toUpperCase(),t||(t={}),!i&&!(i=this.getSelection()))return!1;!i.collapsed&&i.startContainer.nodeType===k&&i.startOffset===i.startContainer.length&&i.startContainer.nextSibling&&i.setStartBefore(i.startContainer.nextSibling),!i.collapsed&&i.endContainer.nodeType===k&&0===i.endOffset&&i.endContainer.previousSibling&&i.setEndAfter(i.endContainer.previousSibling);var r,o,s=i.commonAncestorContainer;if(this.getNearest(s,e,t))return!0;if(s.nodeType===k)return!1;r=new n(s,O,function(e){return re(i,e,!0)},!1);for(var a=!1;o=r.nextNode();){if(!this.getNearest(o,e,t))return!1;a=!0}return a},ee.getFontInfo=function(e){var n,i,r={color:t,backgroundColor:t,family:t,size:t},o=0;if(!e&&!(e=this.getSelection()))return r;if(n=e.commonAncestorContainer,e.collapsed||n.nodeType===k)for(n.nodeType===k&&(n=n.parentNode);4>o&&n&&(i=n.style);)r.color||(r.color=i.color,o+=1),r.backgroundColor||(r.backgroundColor=i.backgroundColor,o+=1),r.family||(r.family=i.fontFamily,o+=1),r.size||(r.size=i.fontSize,o+=1),n=n.parentNode;return r},ee._addFormat=function(e,t,i){var r,o,s,a,d,l,h,c;if(i.collapsed)r=this.fixCursor(this.createElement(e,t)),ie(i,r),i.setStart(r.firstChild,r.firstChild.length),i.collapse(!0);else{if(o=new n(i.commonAncestorContainer,O|B,function(e){return(e.nodeType===k||"BR"===e.nodeName||"IMG"===e.nodeName)&&re(i,e,!0)},!1),s=i.startContainer,d=i.startOffset,a=i.endContainer,l=i.endOffset,o.currentNode=s,o.filter(s)||(s=o.nextNode(),d=0),!s)return i;do h=o.currentNode,c=!this.getNearest(h,e,t),c&&(h===a&&h.length>l&&h.splitText(l),h===s&&d&&(h=h.splitText(d),a===s&&(a=h,l-=d),s=h,d=0),r=this.createElement(e,t),v(h,r),r.appendChild(h));while(o.nextNode());a.nodeType!==k&&(h.nodeType===k?(a=h,l=h.length):(a=h.parentNode,l=1)),i=this._createRange(s,d,a,l)}return i},ee._removeFormat=function(e,t,n,i){this._saveRangeToBookmark(n);var r,s=this._doc;n.collapsed&&(Z?(r=s.createTextNode(U),this._didAddZWS()):r=s.createTextNode(""),ie(n,r));for(var a=n.commonAncestorContainer;d(a);)a=a.parentNode;var l=n.startContainer,h=n.startOffset,c=n.endContainer,f=n.endOffset,u=[],p=function(e,t){if(!re(n,e,!1)){var i,r,o=e.nodeType===k;if(!re(n,e,!0))return void("INPUT"===e.nodeName||o&&!e.data||u.push([t,e]));if(o)e===c&&f!==e.length&&u.push([t,e.splitText(f)]),e===l&&h&&(e.splitText(h),u.push([t,e]));else for(i=e.firstChild;i;i=r)r=i.nextSibling,
  p(i,t)}},g=Array.prototype.filter.call(a.getElementsByTagName(e),function(i){return re(n,i,!0)&&o(i,e,t)});i||g.forEach(function(e){p(e,e)}),u.forEach(function(e){var t=e[0].cloneNode(!1),n=e[1];v(n,t),t.appendChild(n)}),g.forEach(function(e){v(e,C(e))}),this._getRangeAndRemoveBookmark(n),r&&n.collapse(!1);var m={startContainer:n.startContainer,startOffset:n.startOffset,endContainer:n.endContainer,endOffset:n.endOffset};return N(a,m),n.setStart(m.startContainer,m.startOffset),n.setEnd(m.endContainer,m.endOffset),n},ee.changeFormat=function(e,t,n,i){return n||(n=this.getSelection())?(this._recordUndoState(n),this._getRangeAndRemoveBookmark(n),t&&(n=this._removeFormat(t.tag.toUpperCase(),t.attributes||{},n,i)),e&&(n=this._addFormat(e.tag.toUpperCase(),e.attributes||{},n)),this.setSelection(n),this._updatePath(n,!0),j||this._docWasChanged(),this):void 0};var Ue={DT:"DD",DD:"DT",LI:"LI"},Pe=function(e,t,n,r){var s=Ue[t.nodeName],a=null,d=i(e._body,t)?t.parentNode:e._body,l=e.split(n,r,d),h=e._config;return s||(s=h.blockTag,a=h.blockAttributes),o(l,s,a)||(t=_(l.ownerDocument,s,a),l.dir&&(t.dir=l.dir),v(l,t),t.appendChild(C(l)),l=t),l};ee.forEachBlock=function(e,t,n){if(!n&&!(n=this.getSelection()))return this;t&&(this._recordUndoState(n),this._getRangeAndRemoveBookmark(n));var i=ae(n,this),r=de(n,this);if(i&&r)do if(e(i)||i===r)break;while(i=u(i,this));return t&&(this.setSelection(n),this._updatePath(n,!0),j||this._docWasChanged()),this},ee.modifyBlocks=function(e,t){if(!t&&!(t=this.getSelection()))return this;this._isInUndoState?this._saveRangeToBookmark(t):this._recordUndoState(t),fe(t,this);var n,i=this._body;return se(t,i),n=this.extractContentsOfRange(t,i),ie(t,e.call(this,n)),t.endOffset<t.endContainer.childNodes.length&&this.mergeContainers(t.endContainer.childNodes[t.endOffset]),this.mergeContainers(t.startContainer.childNodes[t.startOffset]),this._getRangeAndRemoveBookmark(t),this.setSelection(t),this._updatePath(t,!0),j||this._docWasChanged(),this};var we=function(e){return this.createElement("BLOCKQUOTE",this._config.tagAttributes.blockquote,[e])},Fe=function(e){var t=e.querySelectorAll("blockquote"),n=this;return Array.prototype.filter.call(t,function(e){return!n.getNearest(e.parentNode,"BLOCKQUOTE")}).forEach(function(e){v(e,C(e))}),e},He=function(){return this.createDefaultBlock([this.createElement("INPUT",{id:De,type:"hidden"}),this.createElement("INPUT",{id:Ie,type:"hidden"})])},Me=function(e,t,n){for(var i,r,o,s,a=c(t,e),d=e._config.tagAttributes,l=d[n.toLowerCase()],h=d.li;i=a.nextNode();)r=i.parentNode.nodeName,"LI"!==r?(s=e.createElement("LI",h),i.dir&&(s.dir=i.dir),(o=i.previousSibling)&&o.nodeName===n?o.appendChild(s):v(i,e.createElement(n,l,[s])),s.appendChild(i)):(i=i.parentNode.parentNode,r=i.nodeName,r!==n&&/^[OU]L$/.test(r)&&v(i,e.createElement(n,l,[C(i)])))},We=function(e){return Me(this,e,"UL"),e},Ve=function(e){return Me(this,e,"OL"),e},qe=function(e){var t,n,i,r,o,s,a,d=e.querySelectorAll("UL, OL");for(t=0,n=d.length;n>t;t+=1){for(r=d[t],o=C(r),s=o.childNodes,i=s.length;i--;)a=s[i],v(a,C(a));this.fixContainer(o),v(r,o)}return e},Ke=function(e){var t,n,i,r,o,s,a=e.querySelectorAll("LI"),d=this._config.tagAttributes,l=d.li;for(t=0,n=a.length;n>t;t+=1)i=a[t],h(i.firstChild)||(r=i.parentNode.nodeName,o=i.previousSibling,o&&(o=o.lastChild)&&o.nodeName===r||(s=d[r.toLowerCase()],v(i,this.createElement("LI",l,[o=this.createElement(r,s)]))),o.appendChild(i));return e},ze=function(e){var t=e.querySelectorAll("LI");return Array.prototype.filter.call(t,function(e){return!h(e.firstChild)}).forEach(function(t){var n,i=t.parentNode,r=i.parentNode,o=t.firstChild,s=o;for(t.previousSibling&&(i=this.split(i,t,r));s&&(n=s.nextSibling,!h(s));)r.insertBefore(s,i),s=n;for("LI"===r.nodeName&&o.previousSibling&&this.split(r,o,r.parentNode);t!==e&&!t.childNodes.length;)i=t.parentNode,i.removeChild(t),t=i},this),this.fixContainer(e),e};ee._ensureBottomLine=function(){var e=this._body,t=e.lastElementChild;t&&t.nodeName===this._config.blockTag&&l(t)||e.appendChild(this.createDefaultBlock())},ee.setKeyHandler=function(e,t){return this._keyHandlers[e]=t,this},ee._getHTML=function(e){return e===!1?this._body.innerHTML:this._nodeToHtmlHelper.nodeToHtml(this._body,!0)},ee._nodeToHtmlHelper={VALID_ATTRIBUTE_NAMES:["class","style"],nodeToHtml:function(e,t){var n="";if(e&&1===e.nodeType){var i=e.tagName.toLowerCase();if(t||(n+="<",n+=i,n+=this.attributesToString(e),n+=">"),!/^area|base|br|col|embed|hr|img|input|keygen|link|meta|param|source|track|wbr$/.test(i)){if(e.hasChildNodes())for(var r=0;r<e.childNodes.length;r++)n+=this.nodeToHtml(e.childNodes[r],!1);t||(n+="</"+i+">")}}else e&&3===e.nodeType&&(n+=this.escapeHtml(e.nodeValue));return n},attributesToString:function(e){var t="";if(e&&e.hasAttributes()){var n,i,r=null;for(n=0;n<e.attributes.length;n++){var o=e.attributes[n];i=o.name.toLowerCase(),-1!==this.VALID_ATTRIBUTE_NAMES.indexOf(i)&&(r=r||{},r[i]=o.value)}if(r)for(n=0;n<this.VALID_ATTRIBUTE_NAMES.length;n++)if(i=this.VALID_ATTRIBUTE_NAMES[n],r[i]){var s=r[i];"style"===i&&(s=this.normalizeStyleAttributeValue(s)),t+=" "+i+'="'+this.escapeHtml(s,!0)+'"'}}return t},normalizeStyleAttributeValue:function(e){for(var t=(e||"").split(";"),n=[],i=0;i<t.length;i++){var r=t[i],o=r.indexOf(":");if(-1!==o){var s=r.substr(0,o).trim(),a=r.substr(o+1).trim();n.push(s+": "+a)}}return n.join("; ")},escapeHtml:function(e,t){return e=String(e||""),e=e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),t&&(e=e.replace(/"/g,"&quot;")),e=e.replace(/\u00A0/g,"&nbsp;")}},ee._setHTML=function(e){var t=this._body;t.innerHTML=e;do this.fixCursor(t);while(t=u(t,this));this._ignoreChange=!0},ee.getHTML=function(e){var t,n,i,r,o,s=[];if(e&&(o=this.getSelection())&&this._saveRangeToBookmark(o),z)for(t=this._body;t=u(t,this);)t.textContent||t.querySelector("BR")||(n=this.createElement("BR"),t.appendChild(n),s.push(n));if(i=this._getHTML().replace(/\u200B/g,""),z)for(r=s.length;r--;)m(s[r]);return o&&this._getRangeAndRemoveBookmark(o),i},ee.setHTML=function(e){var t,n=this._doc.createDocumentFragment(),i=this.createElement("DIV");i.innerHTML=e,n.appendChild(C(i)),Ee(n),this.fixContainer(n);for(var r=n;r=u(r,this);)this.fixCursor(r);this._ignoreChange=!0;for(var o=this._body;t=o.lastChild;)o.removeChild(t);o.appendChild(n),this.fixCursor(o),this._undoIndex=-1,this._undoStack.length=0,this._undoStackLength=0,this._isInUndoState=!1;var s=this._getRangeAndRemoveBookmark()||this._createRange(o.firstChild,0);return this._recordUndoState(s),this._getRangeAndRemoveBookmark(s),G?this._lastSelection=s:this.setSelection(s),this._updatePath(s,!0),this},ee.insertElement=function(e,t){if(t||(t=this.getSelection()),t.collapse(!0),d(e))ie(t,e),t.setStartAfter(e);else{for(var n,i,r=this._body,o=ae(t,this)||r;o!==r&&!o.nextSibling;)o=o.parentNode;o!==r&&(n=o.parentNode,i=this.split(n,o.nextSibling,r)),i?r.insertBefore(e,i):(r.appendChild(e),i=this.createDefaultBlock(),r.appendChild(i)),t.setStart(i,0),t.setEnd(i,0),oe(t)}return this.focus(),this.setSelection(t),this._updatePath(t),this},ee.insertImage=function(e,t){var n=this.createElement("IMG",y({src:e},t));return this.insertElement(n),n};var Ze=/\b((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))|([\w\-.%+]+@(?:[\w\-]+\.)+[A-Z]{2,}\b)/i;ee.addLinks=function(e){for(var t,i,r,o,s,a,d,l=e.ownerDocument,h=this,c=new n(e,O,function(e){return!h.getNearest(e,"A")},!1);t=c.nextNode();)for(i=t.data,r=t.parentNode;o=Ze.exec(i);)s=o.index,a=s+o[0].length,s&&(d=l.createTextNode(i.slice(0,s)),r.insertBefore(d,t)),d=l.createElement("A"),d.textContent=i.slice(s,a),d.href=o[1]?/^(?:ht|f)tps?:/.test(o[1])?o[1]:"http://"+o[1]:"mailto:"+o[2],r.insertBefore(d,t),t.data=i=i.slice(a)},ee.insertHTML=function(e,t){var n=this.getSelection(),i=this._doc.createDocumentFragment(),r=this.createElement("DIV");r.innerHTML=e,i.appendChild(C(r)),this._recordUndoState(n),this._getRangeAndRemoveBookmark(n);try{var o=i,s={fragment:i,preventDefault:function(){this.defaultPrevented=!0},defaultPrevented:!1};for(Ee(i),xe(i),i.normalize();o=u(o,this);)this.fixCursor(o);t&&this.fireEvent("willPaste",s),s.defaultPrevented||(this.insertTreeFragmentIntoRange(n,s.fragment,this._body),j||this._docWasChanged(),n.collapse(!1),this._ensureBottomLine()),this.setSelection(n),this._updatePath(n,!0)}catch(a){this.didError(a)}return this},ee.insertPlainText=function(e,t){var n,i,r,o=e.split("\n");for(n=0,i=o.length;i>n;n+=1)r=o[n],r=r.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;").replace(/ (?= )/g,"&nbsp;"),n&&i>n+1&&(r="<DIV>"+(r||"<BR>")+"</DIV>"),o[n]=r;return this.insertHTML(o.join(""),t)};var Ge=function(e,t,n){return function(){return this[e](t,n),this.focus()}};ee.addStyles=function(e){if(e){var t=this._doc.documentElement.firstChild,n=this.createElement("STYLE",{type:"text/css"});n.appendChild(this._doc.createTextNode(e)),t.appendChild(n)}return this},ee.bold=Ge("changeFormat",{tag:"B"}),ee.italic=Ge("changeFormat",{tag:"I"}),ee.underline=Ge("changeFormat",{tag:"U"}),ee.strikethrough=Ge("changeFormat",{tag:"S"}),ee.subscript=Ge("changeFormat",{tag:"SUB"},{tag:"SUP"}),ee.superscript=Ge("changeFormat",{tag:"SUP"},{tag:"SUB"}),ee.removeBold=Ge("changeFormat",null,{tag:"B"}),ee.removeItalic=Ge("changeFormat",null,{tag:"I"}),ee.removeUnderline=Ge("changeFormat",null,{tag:"U"}),ee.removeStrikethrough=Ge("changeFormat",null,{tag:"S"}),ee.removeSubscript=Ge("changeFormat",null,{tag:"SUB"}),ee.removeSuperscript=Ge("changeFormat",null,{tag:"SUP"}),ee.makeLink=function(e,t){var n=this.getSelection();if(n.collapsed){var i=e.indexOf(":")+1;if(i)for(;"/"===e[i];)i+=1;ie(n,this._doc.createTextNode(e.slice(i)))}return t||(t={}),t.href=e,this.changeFormat({tag:"A",attributes:t},{tag:"A"},n),this.focus()},ee.removeLink=function(){return this.changeFormat(null,{tag:"A"},this.getSelection(),!0),this.focus()},ee.setFontFace=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"font",style:"font-family: "+e+", sans-serif;"}},{tag:"SPAN",attributes:{"class":"font"}}),this.focus()},ee.setFontSize=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"size",style:"font-size: "+("number"==typeof e?e+"px":e)}},{tag:"SPAN",attributes:{"class":"size"}}),this.focus()},ee.setTextColour=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"rte-colour",style:"color:"+e}},{tag:"SPAN",attributes:{"class":"rte-colour"}}),this.focus()},ee.removeTextColour=function(){return this.changeFormat(null,{tag:"SPAN",attributes:{"class":"rte-colour"}}),this.focus()},ee.setHighlightColour=function(e){return this.changeFormat({tag:"SPAN",attributes:{"class":"rte-highlight",style:"background-color:"+e}},{tag:"SPAN",attributes:{"class":"rte-highlight"}}),this.focus()},ee.removeHighlightColour=function(){return this.changeFormat(null,{tag:"SPAN",attributes:{"class":"rte-highlight"}}),this.focus()},ee.setTextAlignment=function(e){return this.forEachBlock(function(t){t.className=(t.className.split(/\s+/).filter(function(e){return!/align/.test(e)}).join(" ")+" align-"+e).trim(),t.style.textAlign=e},!0),this.focus()},ee.setTextDirection=function(e){return this.forEachBlock(function(t){t.dir=e},!0),this.focus()},ee.removeAllFormatting=function(e){if(!e&&!(e=this.getSelection())||e.collapsed)return this;for(var t=e.commonAncestorContainer;t&&!l(t);)t=t.parentNode;if(t||(fe(e,this),t=this._body),i(this._body,t)||(t=this._body),t.nodeType===k)return this;this._recordUndoState(e),this._getRangeAndRemoveBookmark(e),se(e,t);for(var n,r,o,s=t.ownerDocument,a=e.startContainer,d=e.startOffset,h=e.endContainer,c=e.endOffset,f=s.createDocumentFragment(),u=s.createDocumentFragment(),p=this.split(h,c,t),g=this.split(a,d,t);g!==p;)n=g.nextSibling,f.appendChild(g),g=n;return T(this,f,u),u.normalize(),g=u.firstChild,n=u.lastChild,o=t.childNodes,g?(t.insertBefore(u,p),d=Q.call(o,g),c=Q.call(o,n)+1):(d=Q.call(o,p),c=d),r={startContainer:t,startOffset:d,endContainer:t,endOffset:c},N(t,r),e.setStart(r.startContainer,r.startOffset),e.setEnd(r.endContainer,r.endOffset),oe(e),this.setSelection(e),this._updatePath(e,!0),this.focus()},ee.increaseQuoteLevel=Ge("modifyBlocks",we),ee.decreaseQuoteLevel=Ge("modifyBlocks",Fe),ee.makeUnorderedList=Ge("modifyBlocks",We),ee.makeOrderedList=Ge("modifyBlocks",Ve),ee.removeList=Ge("modifyBlocks",qe),ee.increaseListLevel=Ge("modifyBlocks",Ke),ee.decreaseListLevel=Ge("modifyBlocks",ze),"object"==typeof exports?module.exports=b:"function"==typeof define&&define.amd?define(function(){return b}):(P.Squire=b,top!==P&&"true"===e.documentElement.getAttribute("data-squireinit")&&(P.editor=new b(e),P.onEditorLoad&&(P.onEditorLoad(P.editor),P.onEditorLoad=null)))}(document);