From 75c524720bdf592f88569640a097932a08d61bb3 Mon Sep 17 00:00:00 2001
From: Neil Jenkins <neil@nmjenkins.com>
Date: Sun, 11 Dec 2016 12:12:18 +1100
Subject: [PATCH] Update to latest release

---
 build/squire-raw.js | 217 ++++++++++++++++++++++++++++----------------
 build/squire.js     |   4 +-
 2 files changed, 140 insertions(+), 81 deletions(-)

diff --git a/build/squire-raw.js b/build/squire-raw.js
index aa117a4..03ea766 100644
--- a/build/squire-raw.js
+++ b/build/squire-raw.js
@@ -47,6 +47,7 @@ var cantFocusEmptyTextNodes = isIElt11 || isWebKit;
 var losesSelectionOnBlur = isIElt11;
 
 var canObserveMutations = typeof MutationObserver !== 'undefined';
+var canWeakMap = typeof WeakMap !== 'undefined';
 
 // Use [^ \t\r\n] instead of \S so that nbsp does not count as white-space
 var notWS = /[^ \t\r\n]/;
@@ -201,25 +202,53 @@ function every ( nodeList, fn ) {
 
 // ---
 
+var UNKNOWN = 0;
+var INLINE = 1;
+var BLOCK = 2;
+var CONTAINER = 3;
+
+var nodeCategoryCache = canWeakMap ? new WeakMap() : null;
+
 function isLeaf ( node ) {
-    return node.nodeType === ELEMENT_NODE &&
-        !!leafNodeNames[ node.nodeName ];
+    return node.nodeType === ELEMENT_NODE && !!leafNodeNames[ node.nodeName ];
 }
-function isInline ( node ) {
-    return inlineNodeNames.test( node.nodeName ) &&
+function getNodeCategory ( node ) {
+    switch ( node.nodeType ) {
+    case TEXT_NODE:
+        return INLINE;
+    case ELEMENT_NODE:
+    case DOCUMENT_FRAGMENT_NODE:
+        if ( canWeakMap && nodeCategoryCache.has( node ) ) {
+            return nodeCategoryCache.get( node );
+        }
+        break;
+    default:
+        return UNKNOWN;
+    }
+
+    var nodeCategory;
+    if ( !every( node.childNodes, isInline ) ) {
         // Malformed HTML can have block tags inside inline tags. Need to treat
         // these as containers rather than inline. See #239.
-        ( node.nodeType === TEXT_NODE || every( node.childNodes, isInline ) );
+        nodeCategory = CONTAINER;
+    } else if ( inlineNodeNames.test( node.nodeName ) ) {
+        nodeCategory = INLINE;
+    } else {
+        nodeCategory = BLOCK;
+    }
+    if ( canWeakMap ) {
+        nodeCategoryCache.set( node, nodeCategory );
+    }
+    return nodeCategory;
+}
+function isInline ( node ) {
+    return getNodeCategory( node ) === INLINE;
 }
 function isBlock ( node ) {
-    var type = node.nodeType;
-    return ( type === ELEMENT_NODE || type === DOCUMENT_FRAGMENT_NODE ) &&
-        !isInline( node ) && every( node.childNodes, isInline );
+    return getNodeCategory( node ) === BLOCK;
 }
 function isContainer ( node ) {
-    var type = node.nodeType;
-    return ( type === ELEMENT_NODE || type === DOCUMENT_FRAGMENT_NODE ) &&
-        !isInline( node ) && !isBlock( node );
+    return getNodeCategory( node ) === CONTAINER;
 }
 
 function getBlockWalker ( node, root ) {
@@ -374,13 +403,14 @@ function fixCursor ( node, root ) {
     // unfocussable if they have no content. To remedy this, a <BR> must be
     // inserted. In Opera and IE, we just need a textnode in order for the
     // cursor to appear.
-    var doc = node.ownerDocument,
-        originalNode = node,
-        fixer, child;
+    var self = root.__squire__;
+    var doc = node.ownerDocument;
+    var originalNode = node;
+    var fixer, child;
 
     if ( node === root ) {
         if ( !( child = node.firstChild ) || child.nodeName === 'BR' ) {
-            fixer = getSquireInstance( doc ).createDefaultBlock();
+            fixer = self.createDefaultBlock();
             if ( child ) {
                 node.replaceChild( fixer, child );
             }
@@ -406,7 +436,7 @@ function fixCursor ( node, root ) {
         if ( !child ) {
             if ( cantFocusEmptyTextNodes ) {
                 fixer = doc.createTextNode( ZWS );
-                getSquireInstance( doc )._didAddZWS();
+                self._didAddZWS();
             } else {
                 fixer = doc.createTextNode( '' );
             }
@@ -442,7 +472,7 @@ function fixCursor ( node, root ) {
         try {
             node.appendChild( fixer );
         } catch ( error ) {
-            getSquireInstance( doc ).didError({
+            self.didError({
                 name: 'Squire: fixCursor – ' + error,
                 message: 'Parent: ' + node.nodeName + '/' + node.innerHTML +
                     ' appendChild: ' + fixer.nodeName
@@ -455,11 +485,11 @@ function fixCursor ( node, root ) {
 
 // Recursively examine container nodes and wrap any inline children.
 function fixContainer ( container, root ) {
-    var children = container.childNodes,
-        doc = container.ownerDocument,
-        wrapper = null,
-        i, l, child, isBR,
-        config = getSquireInstance( doc )._config;
+    var children = container.childNodes;
+    var doc = container.ownerDocument;
+    var wrapper = null;
+    var i, l, child, isBR;
+    var config = root.__squire__._config;
 
     for ( i = 0, l = children.length; i < l; i += 1 ) {
         child = children[i];
@@ -867,7 +897,7 @@ var deleteContentsOfRange = function ( range, root ) {
         fixCursor( root, root );
         range.selectNodeContents( root.firstChild );
     } else {
-        range.collapse( false );
+        range.collapse( range.endContainer === root ? true : false );
     }
     return frag;
 };
@@ -1865,7 +1895,7 @@ var stylesRewriters = {
             newTreeBottom, newTreeTop;
         if ( face ) {
             fontSpan = createElement( doc, 'SPAN', {
-                'class': 'font',
+                'class': FONT_FAMILY_CLASS,
                 style: 'font-family:' + face
             });
             newTreeTop = fontSpan;
@@ -1873,7 +1903,7 @@ var stylesRewriters = {
         }
         if ( size ) {
             sizeSpan = createElement( doc, 'SPAN', {
-                'class': 'size',
+                'class': FONT_SIZE_CLASS,
                 style: 'font-size:' + fontSizes[ size ] + 'px'
             });
             if ( !newTreeTop ) {
@@ -1889,7 +1919,7 @@ var stylesRewriters = {
                 colour = '#' + colour;
             }
             colourSpan = createElement( doc, 'SPAN', {
-                'class': 'colour',
+                'class': COLOUR_CLASS,
                 style: 'color:' + colour
             });
             if ( !newTreeTop ) {
@@ -1909,7 +1939,7 @@ var stylesRewriters = {
     },
     TT: function ( node, parent ) {
         var el = createElement( node.ownerDocument, 'SPAN', {
-            'class': 'font',
+            'class': FONT_FAMILY_CLASS,
             style: 'font-family:menlo,consolas,"courier new",monospace'
         });
         parent.replaceChild( el, node );
@@ -2155,7 +2185,7 @@ var onCopy = function ( event ) {
         range = range.cloneRange();
         startBlock = getStartBlockOfRange( range, root );
         endBlock = getEndBlockOfRange( range, root );
-        copyRoot = ( startBlock === endBlock ) ? startBlock : root;
+        copyRoot = ( ( startBlock === endBlock ) && startBlock ) || root;
         moveRangeBoundariesDownTree( range );
         moveRangeBoundariesUpTree( range, copyRoot );
         contents = range.cloneContents();
@@ -2234,7 +2264,7 @@ var onPaste = function ( event ) {
                 });
             }
         } else if ( plainItem ) {
-            item.getAsString( function ( text ) {
+            plainItem.getAsString( function ( text ) {
                 self.insertPlainText( text, true );
             });
         }
@@ -2364,20 +2394,6 @@ var onDrop = function ( event ) {
     }
 };
 
-var instances = [];
-
-function getSquireInstance ( doc ) {
-    var l = instances.length,
-        instance;
-    while ( l-- ) {
-        instance = instances[l];
-        if ( instance._doc === doc ) {
-            return instance;
-        }
-    }
-    return null;
-}
-
 function mergeObjects ( base, extras, mayOverride ) {
     var prop, value;
     if ( !base ) {
@@ -2518,7 +2534,7 @@ function Squire ( root, config ) {
         doc.execCommand( 'enableInlineTableEditing', false, 'false' );
     } catch ( error ) {}
 
-    instances.push( this );
+    root.__squire__ = this;
 
     // Need to register instance before calling setHTML, so that the fixCursor
     // function can lookup any default block tag options set.
@@ -2527,6 +2543,15 @@ function Squire ( root, config ) {
 
 var proto = Squire.prototype;
 
+var sanitizeToDOMFragment = function ( html/*, isPaste*/ ) {
+    var frag = DOMPurify.sanitize( html, {
+        WHOLE_DOCUMENT: false,
+        RETURN_DOM: true,
+        RETURN_DOM_FRAGMENT: true
+    });
+    return doc.importNode( frag, true );
+};
+
 proto.setConfig = function ( config ) {
     config = mergeObjects({
         blockTag: 'DIV',
@@ -2542,7 +2567,13 @@ proto.setConfig = function ( config ) {
         undo: {
             documentSizeThreshold: -1, // -1 means no threshold
             undoLimit: -1 // -1 means no limit
-        }
+        },
+        isInsertedHTMLSanitized: true,
+        isSetHTMLSanitized: true,
+        sanitizeToDOMFragment:
+            typeof DOMPurify !== 'undefined' && DOMPurify.isSupported ?
+            sanitizeToDOMFragment : null
+
     }, config, true );
 
     // Users may specify block tag in lower case
@@ -2592,6 +2623,7 @@ proto.modifyDocument = function ( modificationCallback ) {
             characterData: true,
             subtree: true
         });
+        this._ignoreChange = false;
     }
 };
 
@@ -2653,7 +2685,6 @@ proto.fireEvent = function ( type, event ) {
 };
 
 proto.destroy = function () {
-    var l = instances.length;
     var events = this._events;
     var type;
 
@@ -2663,11 +2694,7 @@ proto.destroy = function () {
     if ( this._mutation ) {
         this._mutation.disconnect();
     }
-    while ( l-- ) {
-        if ( instances[l] === this ) {
-            instances.splice( l, 1 );
-        }
-    }
+    delete this._root.__squire__;
 
     // Destroy undo stack
     this._undoIndex = -1;
@@ -3109,6 +3136,9 @@ proto._keyUpDetectChange = function ( event ) {
 };
 
 proto._docWasChanged = function () {
+    if ( canWeakMap ) {
+        nodeCategoryCache = new WeakMap();
+    }
     if ( this._ignoreAllChanges ) {
         return;
     }
@@ -3934,14 +3964,21 @@ proto.getHTML = function ( withBookMark ) {
 };
 
 proto.setHTML = function ( html ) {
-    var frag = this._doc.createDocumentFragment();
-    var div = this.createElement( 'DIV' );
+    var config = this._config;
+    var sanitizeToDOMFragment = config.isSetHTMLSanitized ?
+            config.sanitizeToDOMFragment : null;
     var root = this._root;
-    var child;
+    var div, frag, child;
 
     // Parse HTML into DOM tree
-    div.innerHTML = html;
-    frag.appendChild( empty( div ) );
+    if ( typeof sanitizeToDOMFragment === 'function' ) {
+        frag = sanitizeToDOMFragment( html, false );
+    } else {
+        div = this.createElement( 'DIV' );
+        div.innerHTML = html;
+        frag = this._doc.createDocumentFragment();
+        frag.appendChild( empty( div ) );
+    }
 
     cleanTree( frag );
     cleanupBRs( frag, root );
@@ -4076,6 +4113,9 @@ var addLinks = function ( frag, root, self ) {
 // insertTreeFragmentIntoRange will delete the selection so that it is replaced
 // by the html being inserted.
 proto.insertHTML = function ( html, isPaste ) {
+    var config = this._config;
+    var sanitizeToDOMFragment = config.isInsertedHTMLSanitized ?
+            config.sanitizeToDOMFragment : null;
     var range = this.getSelection();
     var doc = this._doc;
     var startFragmentIndex, endFragmentIndex;
@@ -4084,13 +4124,8 @@ proto.insertHTML = function ( html, isPaste ) {
     // Edge doesn't just copy the fragment, but includes the surrounding guff
     // including the full <head> of the page. Need to strip this out. If
     // available use DOMPurify to parse and sanitise.
-    if ( typeof DOMPurify !== 'undefined' && DOMPurify.isSupported ) {
-        frag = DOMPurify.sanitize( html, {
-            WHOLE_DOCUMENT: false,
-            RETURN_DOM: true,
-            RETURN_DOM_FRAGMENT: true
-        });
-        frag = doc.importNode( frag, true );
+    if ( typeof sanitizeToDOMFragment === 'function' ) {
+        frag = sanitizeToDOMFragment( html, isPaste );
     } else {
         if ( isPaste ) {
             startFragmentIndex = html.indexOf( '<!--StartFragment-->' );
@@ -4122,12 +4157,12 @@ proto.insertHTML = function ( html, isPaste ) {
 
         addLinks( frag, frag, this );
         cleanTree( frag );
-        cleanupBRs( frag, null );
+        cleanupBRs( frag, root );
         removeEmptyInlines( frag );
         frag.normalize();
 
         while ( node = getNextBlock( node, frag ) ) {
-            fixCursor( node, null );
+            fixCursor( node, root );
         }
 
         if ( isPaste ) {
@@ -4264,12 +4299,12 @@ proto.setFontFace = function ( name ) {
     this.changeFormat( name ? {
         tag: 'SPAN',
         attributes: {
-            'class': 'font',
+            'class': FONT_FAMILY_CLASS,
             style: 'font-family: ' + name + ', sans-serif;'
         }
     } : null, {
         tag: 'SPAN',
-        attributes: { 'class': 'font' }
+        attributes: { 'class': FONT_FAMILY_CLASS }
     });
     return this.focus();
 };
@@ -4277,13 +4312,13 @@ proto.setFontSize = function ( size ) {
     this.changeFormat( size ? {
         tag: 'SPAN',
         attributes: {
-            'class': 'size',
+            'class': FONT_SIZE_CLASS,
             style: 'font-size: ' +
                 ( typeof size === 'number' ? size + 'px' : size )
         }
     } : null, {
         tag: 'SPAN',
-        attributes: { 'class': 'size' }
+        attributes: { 'class': FONT_SIZE_CLASS }
     });
     return this.focus();
 };
@@ -4292,12 +4327,12 @@ proto.setTextColour = function ( colour ) {
     this.changeFormat( colour ? {
         tag: 'SPAN',
         attributes: {
-            'class': 'colour',
+            'class': COLOUR_CLASS,
             style: 'color:' + colour
         }
     } : null, {
         tag: 'SPAN',
-        attributes: { 'class': 'colour' }
+        attributes: { 'class': COLOUR_CLASS }
     });
     return this.focus();
 };
@@ -4306,33 +4341,42 @@ proto.setHighlightColour = function ( colour ) {
     this.changeFormat( colour ? {
         tag: 'SPAN',
         attributes: {
-            'class': 'highlight',
+            'class': HIGHLIGHT_CLASS,
             style: 'background-color:' + colour
         }
     } : colour, {
         tag: 'SPAN',
-        attributes: { 'class': 'highlight' }
+        attributes: { 'class': HIGHLIGHT_CLASS }
     });
     return this.focus();
 };
 
 proto.setTextAlignment = function ( alignment ) {
     this.forEachBlock( function ( block ) {
-        block.className = ( block.className
+        var className = block.className
             .split( /\s+/ )
             .filter( function ( klass ) {
-                return !( /align/.test( klass ) );
+                return !!klass && !/^align/.test( klass );
             })
-            .join( ' ' ) +
-            ' align-' + alignment ).trim();
-        block.style.textAlign = alignment;
+            .join( ' ' );
+        if ( alignment ) {
+            block.className = className + ' align-' + alignment;
+            block.style.textAlign = alignment;
+        } else {
+            block.className = className;
+            block.style.textAlign = '';
+        }
     }, true );
     return this.focus();
 };
 
 proto.setTextDirection = function ( direction ) {
     this.forEachBlock( function ( block ) {
-        block.dir = direction;
+        if ( direction ) {
+            block.dir = direction;
+        } else {
+            block.removeAttribute( 'dir' );
+        }
     }, true );
     return this.focus();
 };
@@ -4446,6 +4490,21 @@ proto.removeList = command( 'modifyBlocks', removeList );
 proto.increaseListLevel = command( 'modifyBlocks', increaseListLevel );
 proto.decreaseListLevel = command( 'modifyBlocks', decreaseListLevel );
 
+// Node.js exports
+Squire.isInline = isInline;
+Squire.isBlock = isBlock;
+Squire.isContainer = isContainer;
+Squire.getBlockWalker = getBlockWalker;
+Squire.getPreviousBlock = getPreviousBlock;
+Squire.getNextBlock = getNextBlock;
+Squire.areAlike = areAlike;
+Squire.hasTagAttributes = hasTagAttributes;
+Squire.getNearest = getNearest;
+Squire.isOrContains = isOrContains;
+Squire.detach = detach;
+Squire.replaceWith = replaceWith;
+Squire.empty = empty;
+
 // Range.js exports
 Squire.getNodeBefore = getNodeBefore;
 Squire.getNodeAfter = getNodeAfter;
diff --git a/build/squire.js b/build/squire.js
index 2bce274..5e2074f 100644
--- a/build/squire.js
+++ b/build/squire.js
@@ -1,2 +1,2 @@
-!function(e,t){"use strict";function n(e,t,n){this.root=this.currentNode=e,this.nodeType=t,this.filter=n}function o(e,t){for(var n=e.length;n--;)if(!t(e[n]))return!1;return!0}function r(e){return e.nodeType===w&&!!Ct[e.nodeName]}function i(e){return vt.test(e.nodeName)&&(e.nodeType===F||o(e.childNodes,i))}function a(e){var t=e.nodeType;return(t===w||t===H)&&!i(e)&&o(e.childNodes,i)}function s(e){var t=e.nodeType;return!(t!==w&&t!==H||i(e)||a(e))}function d(e,t){var o=new n(t,W,a);return o.currentNode=e,o}function l(e,t){return e=d(e,t).previousNode(),e!==t?e:null}function c(e,t){return e=d(e,t).nextNode(),e!==t?e:null}function h(e,t){return!r(e)&&e.nodeType===t.nodeType&&e.nodeName===t.nodeName&&"A"!==e.nodeName&&e.className===t.className&&(!e.style&&!t.style||e.style.cssText===t.style.cssText)}function u(e,t,n){if(e.nodeName!==t)return!1;for(var o in n)if(e.getAttribute(o)!==n[o])return!1;return!0}function f(e,t,n,o){for(;e&&e!==t;){if(u(e,n,o))return e;e=e.parentNode}return null}function p(e,t){for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function g(e,t){var n,o,r,i,a="";return e&&e!==t&&(a=g(e.parentNode,t),e.nodeType===w&&(a+=(a?">":"")+e.nodeName,(n=e.id)&&(a+="#"+n),(o=e.className.trim())&&(r=o.split(/\s\s*/),r.sort(),a+=".",a+=r.join(".")),(i=e.dir)&&(a+="[dir="+i+"]"),r&&(gt.call(r,j)>-1&&(a+="[backgroundColor="+e.style.backgroundColor.replace(/ /g,"")+"]"),gt.call(r,Q)>-1&&(a+="[color="+e.style.color.replace(/ /g,"")+"]"),gt.call(r,V)>-1&&(a+="[fontFamily="+e.style.fontFamily.replace(/ /g,"")+"]"),gt.call(r,$)>-1&&(a+="[fontSize="+e.style.fontSize+"]")))),a}function m(e){var t=e.nodeType;return t===w?e.childNodes.length:e.length||0}function v(e){var t=e.parentNode;return t&&t.removeChild(e),e}function C(e,t){var n=e.parentNode;n&&n.replaceChild(t,e)}function N(e){for(var t=e.ownerDocument.createDocumentFragment(),n=e.childNodes,o=n?n.length:0;o--;)t.appendChild(e.firstChild);return t}function _(e,n,o,r){var i,a,s,d,l=e.createElement(n);if(o instanceof Array&&(r=o,o=null),o)for(i in o)a=o[i],a!==t&&l.setAttribute(i,o[i]);if(r)for(s=0,d=r.length;d>s;s+=1)l.appendChild(r[s]);return l}function S(e,t){var n,o,a=e.ownerDocument,s=e;if(e===t&&((o=e.firstChild)&&"BR"!==o.nodeName||(n=L(a).createDefaultBlock(),o?e.replaceChild(n,o):e.appendChild(n),e=n,n=null)),e.nodeType===F)return s;if(i(e)){for(o=e.firstChild;ht&&o&&o.nodeType===F&&!o.data;)e.removeChild(o),o=e.firstChild;o||(ht?(n=a.createTextNode(Y),L(a)._didAddZWS()):n=a.createTextNode(""))}else if(ct){for(;e.nodeType!==F&&!r(e);){if(o=e.firstChild,!o){n=a.createTextNode("");break}e=o}e.nodeType===F?/^ +$/.test(e.data)&&(e.data=""):r(e)&&e.parentNode.insertBefore(a.createTextNode(""),e)}else if(!e.querySelector("BR"))for(n=_(a,"BR");(o=e.lastElementChild)&&!i(o);)e=o;if(n)try{e.appendChild(n)}catch(d){L(a).didError({name:"Squire: fixCursor – "+d,message:"Parent: "+e.nodeName+"/"+e.innerHTML+" appendChild: "+n.nodeName})}return s}function y(e,t){var n,o,r,a,d=e.childNodes,l=e.ownerDocument,c=null,h=L(l)._config;for(n=0,o=d.length;o>n;n+=1)r=d[n],a="BR"===r.nodeName,!a&&i(r)?(c||(c=_(l,h.blockTag,h.blockAttributes)),c.appendChild(r),n-=1,o-=1):(a||c)&&(c||(c=_(l,h.blockTag,h.blockAttributes)),S(c,t),a?e.replaceChild(c,r):(e.insertBefore(c,r),n+=1,o+=1),c=null),s(r)&&y(r,t);return c&&e.appendChild(S(c,t)),e}function T(e,t,n,o){var r,i,a,s=e.nodeType;if(s===F&&e!==n)return T(e.parentNode,e.splitText(t),n,o);if(s===w){if("number"==typeof t&&(t=t<e.childNodes.length?e.childNodes[t]:null),e===n)return t;for(r=e.parentNode,i=e.cloneNode(!1);t;)a=t.nextSibling,i.appendChild(t),t=a;return"OL"===e.nodeName&&f(e,o,"BLOCKQUOTE")&&(i.start=(+e.start||1)+e.childNodes.length-1),S(e,o),S(i,o),(a=e.nextSibling)?r.insertBefore(i,a):r.appendChild(i),T(r,i,n,o)}return t}function b(e,t){for(var n,o,r,a=e.childNodes,s=a.length,d=[];s--;)if(n=a[s],o=s&&a[s-1],s&&i(n)&&h(n,o)&&!Ct[n.nodeName])t.startContainer===n&&(t.startContainer=o,t.startOffset+=m(o)),t.endContainer===n&&(t.endContainer=o,t.endOffset+=m(o)),t.startContainer===e&&(t.startOffset>s?t.startOffset-=1:t.startOffset===s&&(t.startContainer=o,t.startOffset=m(o))),t.endContainer===e&&(t.endOffset>s?t.endOffset-=1:t.endOffset===s&&(t.endContainer=o,t.endOffset=m(o))),v(n),n.nodeType===F?o.appendData(n.data):d.push(N(n));else if(n.nodeType===w){for(r=d.length;r--;)n.appendChild(d.pop());b(n,t)}}function E(e,t){if(e.nodeType===F&&(e=e.parentNode),e.nodeType===w){var n={startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset};b(e,n),t.setStart(n.startContainer,n.startOffset),t.setEnd(n.endContainer,n.endOffset)}}function k(e,t,n){for(var o,r,i=t;1===i.parentNode.childNodes.length;)i=i.parentNode;v(i),r=e.childNodes.length,o=e.lastChild,o&&"BR"===o.nodeName&&(e.removeChild(o),r-=1),e.appendChild(N(t)),n.setStart(e,r),n.collapse(!0),E(e,n),it&&(o=e.lastChild)&&"BR"===o.nodeName&&e.removeChild(o)}function B(e,t){var n,o,r=e.previousSibling,i=e.firstChild,a=e.ownerDocument,d="LI"===e.nodeName;if(!d||i&&/^[OU]L$/.test(i.nodeName))if(r&&h(r,e)){if(!s(r)){if(!d)return;o=_(a,"DIV"),o.appendChild(N(r)),r.appendChild(o)}v(e),n=!s(e),r.appendChild(N(e)),n&&y(r,t),i&&B(i,t)}else d&&(r=_(a,"DIV"),e.insertBefore(r,i),S(r,t))}function x(e){this.isShiftDown=e.shiftKey}function L(e){for(var t,n=rn.length;n--;)if(t=rn[n],t._doc===e)return t;return null}function A(e,t,n){var o,r;if(e||(e={}),t)for(o in t)!n&&o in e||(r=t[o],e[o]=r&&r.constructor===Object?A(e[o],r,n):r);return e}function O(e,t){e.nodeType===M&&(e=e.body);var n,o=e.ownerDocument,r=o.defaultView;this._win=r,this._doc=o,this._root=e,this._events={},this._isFocused=!1,this._lastSelection=null,ut&&this.addEventListener("beforedeactivate",this.getSelection),this._hasZWS=!1,this._lastAnchorNode=null,this._lastFocusNode=null,this._path="",this._willUpdatePath=!1,"onselectionchange"in o?this.addEventListener("selectionchange",this._updatePathOnEvent):(this.addEventListener("keyup",this._updatePathOnEvent),this.addEventListener("mouseup",this._updatePathOnEvent)),this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0,this._isInUndoState=!1,this._ignoreChange=!1,this._ignoreAllChanges=!1,ft?(n=new MutationObserver(this._docWasChanged.bind(this)),n.observe(e,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),this._mutation=n):this.addEventListener("keyup",this._keyUpDetectChange),this._restoreSelection=!1,this.addEventListener("blur",R),this.addEventListener("mousedown",D),this.addEventListener("touchstart",D),this.addEventListener("focus",U),this._awaitingPaste=!1,this.addEventListener(rt?"beforecut":"cut",en),this.addEventListener("copy",tn),this.addEventListener("keydown",x),this.addEventListener("keyup",x),this.addEventListener(rt?"beforepaste":"paste",nn),this.addEventListener("drop",on),this.addEventListener(it?"keypress":"keydown",Pt),this._keyHandlers=Object.create(Mt),this.setConfig(t),rt&&(r.Text.prototype.splitText=function(e){var t=this.ownerDocument.createTextNode(this.data.slice(e)),n=this.nextSibling,o=this.parentNode,r=this.length-e;return n?o.insertBefore(t,n):o.appendChild(t),r&&this.deleteData(e,r),t}),e.setAttribute("contenteditable","true");try{o.execCommand("enableObjectResizing",!1,"false"),o.execCommand("enableInlineTableEditing",!1,"false")}catch(i){}rn.push(this),this.setHTML("")}function R(){this._restoreSelection=!0}function D(){this._restoreSelection=!1}function U(){this._restoreSelection&&this.setSelection(this._lastSelection)}function P(e,t,n){var o,r;for(o=t.firstChild;o;o=r){if(r=o.nextSibling,i(o)){if(o.nodeType===F||"BR"===o.nodeName||"IMG"===o.nodeName){n.appendChild(o);continue}}else if(a(o)){n.appendChild(e.createDefaultBlock([P(e,o,e._doc.createDocumentFragment())]));continue}P(e,o,n)}return n}var I=2,w=1,F=3,M=9,H=11,W=1,z=4,q=0,K=1,G=2,Z=3,j="highlight",Q="colour",V="font",$="size",Y="​",X=e.defaultView,J=navigator.userAgent,et=/iP(?:ad|hone|od)/.test(J),tt=/Mac OS X/.test(J),nt=/Android/.test(J),ot=/Gecko\//.test(J),rt=/Trident\/[456]\./.test(J),it=!!X.opera,at=/Edge\//.test(J),st=!at&&/WebKit\//.test(J),dt=/Trident\/[4567]\./.test(J),lt=tt?"meta-":"ctrl-",ct=rt||it,ht=rt||st,ut=rt,ft="undefined"!=typeof MutationObserver,pt=/[^ \t\r\n]/,gt=Array.prototype.indexOf;Object.create||(Object.create=function(e){var t=function(){};return t.prototype=e,new t});var mt={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,o=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(mt[e.nodeType]&o&&r(e))return this.currentNode=e,e;t=e}},n.prototype.previousNode=function(){for(var e,t=this.currentNode,n=this.root,o=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(mt[e.nodeType]&o&&r(e))return this.currentNode=e,e;t=e}},n.prototype.previousPONode=function(){for(var e,t=this.currentNode,n=this.root,o=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(mt[e.nodeType]&o&&r(e))return this.currentNode=e,e;t=e}};var vt=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,Ct={BR:1,HR:1,IFRAME:1,IMG:1,INPUT:1},Nt=function(e,t){for(var n=e.childNodes;t&&e.nodeType===w;)e=n[t-1],n=e.childNodes,t=n.length;return e},_t=function(e,t){if(e.nodeType===w){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},St=function(e,t){var n,o,r,i,a=e.startContainer,s=e.startOffset,d=e.endContainer,l=e.endOffset;a.nodeType===F?(n=a.parentNode,o=n.childNodes,s===a.length?(s=gt.call(o,a)+1,e.collapsed&&(d=n,l=s)):(s&&(i=a.splitText(s),d===a?(l-=s,d=i):d===n&&(l+=1),a=i),s=gt.call(o,a)),a=n):o=a.childNodes,r=o.length,s===r?a.appendChild(t):a.insertBefore(t,o[s]),a===d&&(l+=o.length-r),e.setStart(a,s),e.setEnd(d,l)},yt=function(e,t,n){var o=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset;t||(t=e.commonAncestorContainer),t.nodeType===F&&(t=t.parentNode);for(var s,d,l,c=T(i,a,t,n),h=T(o,r,t,n),u=t.ownerDocument.createDocumentFragment();h!==c;)s=h.nextSibling,u.appendChild(h),h=s;return o=t,r=c?gt.call(t.childNodes,c):t.childNodes.length,l=t.childNodes[r],d=l&&l.previousSibling,d&&d.nodeType===F&&l.nodeType===F&&(o=d,r=d.length,d.appendData(l.data),v(l)),e.setStart(o,r),e.collapse(!0),S(t,n),u},Tt=function(e,t){Bt(e);var n=e.startContainer,o=e.endContainer,r=(i(n)||a(n))&&(i(o)||a(o)),s=yt(e,null,t);kt(e),n=xt(e,t),r&&(o=Lt(e,t),n&&o&&n!==o&&k(n,o,e)),n&&S(n,t);var d=t.firstChild;return d&&"BR"!==d.nodeName?e.collapse(!1):(S(t,t),e.selectNodeContents(t.firstChild)),s},bt=function(e,t,n){for(var o=!0,r=t.childNodes,d=r.length;d--;)if(!i(r[d])){o=!1;break}if(e.collapsed||Tt(e,n),kt(e),o)St(e,t),e.startContainer!==e.endContainer&&E(e.endContainer,e),E(e.startContainer,e),e.collapse(!1);else{for(var h,u,p,g,m,v=e.startContainer,C=T(v,e.startOffset,f(v.parentNode,n,"BLOCKQUOTE")||n,n),N=C.previousSibling,_=N,y=_.childNodes.length,b=C,k=0,x=C.parentNode;(h=_.lastChild)&&h.nodeType===w;){if("BR"===h.nodeName){y-=1;break}_=h,y=_.childNodes.length}for(;(h=b.firstChild)&&h.nodeType===w&&"BR"!==h.nodeName;)b=h;for(m=_.childNodes[y]||null;(h=t.firstChild)&&i(h);)_.insertBefore(h,m);for(;(h=t.lastChild)&&i(h);)b.insertBefore(h,b.firstChild),k+=1;for(u=t;u=c(u,n);)S(u,n);if(x.insertBefore(t,C),g=N.nextSibling,u=l(g,n),u&&!/\S/.test(u.textContent))do x=u.parentNode,x.removeChild(u),u=x;while(u&&!u.lastChild&&u!==n);if(N.parentNode||(N=g.previousSibling),_.parentNode||(_=N||g.parentNode,y=N?N.childNodes.length:0),s(g)&&B(g,n),p=C.previousSibling,u=a(C)?C:c(C,n),u&&!/\S/.test(u.textContent))do x=u.parentNode,x.removeChild(u),u=x;while(u&&!u.lastChild&&u!==n);C.parentNode||(C=p.nextSibling),k||(b=p,k=p.childNodes.length),C&&s(C)&&B(C,n),e.setStart(_,y),e.setEnd(b,k),kt(e)}},Et=function(e,t,n){var o=t.ownerDocument.createRange();if(o.selectNode(t),n){var r=e.compareBoundaryPoints(Z,o)>-1,i=e.compareBoundaryPoints(K,o)<1;return!r&&!i}var a=e.compareBoundaryPoints(q,o)<1,s=e.compareBoundaryPoints(G,o)>-1;return a&&s},kt=function(e){for(var t,n=e.startContainer,o=e.startOffset,i=e.endContainer,a=e.endOffset,s=!0;n.nodeType!==F&&(t=n.childNodes[o],t&&!r(t));)n=t,o=0;if(a)for(;i.nodeType!==F;){if(t=i.childNodes[a-1],!t||r(t)){if(s&&t&&"BR"===t.nodeName){a-=1,s=!1;continue}break}i=t,a=m(i)}else for(;i.nodeType!==F&&(t=i.firstChild,t&&!r(t));)i=t;e.collapsed?(e.setStart(i,a),e.setEnd(n,o)):(e.setStart(n,o),e.setEnd(i,a))},Bt=function(e,t){var n,o=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,s=!0;for(t||(t=e.commonAncestorContainer);o!==t&&!r;)n=o.parentNode,r=gt.call(n.childNodes,o),o=n;for(;;){if(s&&i.nodeType!==F&&i.childNodes[a]&&"BR"===i.childNodes[a].nodeName&&(a+=1,s=!1),i===t||a!==m(i))break;n=i.parentNode,a=gt.call(n.childNodes,i)+1,i=n}e.setStart(o,r),e.setEnd(i,a)},xt=function(e,t){var n,o=e.startContainer;return i(o)?n=l(o,t):o!==t&&a(o)?n=o:(n=Nt(o,e.startOffset),n=c(n,t)),n&&Et(e,n,!0)?n:null},Lt=function(e,t){var n,o,r=e.endContainer;if(i(r))n=l(r,t);else if(r!==t&&a(r))n=r;else{if(n=_t(r,e.endOffset),!n||!p(t,n))for(n=t;o=n.lastChild;)n=o;n=l(n,t)}return n&&Et(e,n,!0)?n:null},At=new n(null,z|W,function(e){return e.nodeType===F?pt.test(e.data):"IMG"===e.nodeName}),Ot=function(e,t){var n,o=e.startContainer,r=e.startOffset;if(At.root=null,o.nodeType===F){if(r)return!1;n=o}else if(n=_t(o,r),n&&!p(t,n)&&(n=null),!n&&(n=Nt(o,r),n.nodeType===F&&n.length))return!1;return At.currentNode=n,At.root=xt(e,t),!At.previousNode()},Rt=function(e,t){var n,o=e.endContainer,r=e.endOffset;if(At.root=null,o.nodeType===F){if(n=o.data.length,n&&n>r)return!1;At.currentNode=o}else At.currentNode=Nt(o,r);return At.root=Lt(e,t),!At.nextNode()},Dt=function(e,t){var n,o=xt(e,t),r=Lt(e,t);o&&r&&(n=o.parentNode,e.setStart(n,gt.call(n.childNodes,o)),n=r.parentNode,e.setEnd(n,gt.call(n.childNodes,r)+1))},Ut={8:"backspace",9:"tab",13:"enter",32:"space",33:"pageup",34:"pagedown",37:"left",39:"right",46:"delete",219:"[",221:"]"},Pt=function(e){var t=e.keyCode,n=Ut[t],o="",r=this.getSelection();e.defaultPrevented||(n||(n=String.fromCharCode(t).toLowerCase(),/^[A-Za-z0-9]$/.test(n)||(n="")),it&&46===e.which&&(n="."),t>111&&124>t&&(n="f"+(t-111)),"backspace"!==n&&"delete"!==n&&(e.altKey&&(o+="alt-"),e.ctrlKey&&(o+="ctrl-"),e.metaKey&&(o+="meta-")),e.shiftKey&&(o+="shift-"),n=o+n,this._keyHandlers[n]?this._keyHandlers[n](this,e,r):1!==n.length||r.collapsed||(this.saveUndoState(r),Tt(r,this._root),this._ensureBottomLine(),this.setSelection(r),this._updatePath(r,!0)))},It=function(e){return function(t,n){n.preventDefault(),t[e]()}},wt=function(e,t){return t=t||null,function(n,o){o.preventDefault();var r=n.getSelection();n.hasFormat(e,null,r)?n.changeFormat(null,{tag:e},r):n.changeFormat({tag:e},t,r)}},Ft=function(e,t){try{t||(t=e.getSelection());var n,o=t.startContainer;for(o.nodeType===F&&(o=o.parentNode),n=o;i(n)&&(!n.textContent||n.textContent===Y);)o=n,n=o.parentNode;o!==n&&(t.setStart(n,gt.call(n.childNodes,o)),t.collapse(!0),n.removeChild(o),a(n)||(n=l(n,e._root)),S(n,e._root),kt(t)),o===e._root&&(o=o.firstChild)&&"BR"===o.nodeName&&v(o),e._ensureBottomLine(),e.setSelection(t),e._updatePath(t,!0)}catch(r){e.didError(r)}},Mt={enter:function(e,t,n){var o,r,i,a=e._root;if(t.preventDefault(),e._recordUndoState(n),bn(n.startContainer,a,e),e._removeZWS(),e._getRangeAndRemoveBookmark(n),n.collapsed||Tt(n,a),o=xt(n,a),!o||/^T[HD]$/.test(o.nodeName))return St(n,e.createElement("BR")),n.collapse(!1),e.setSelection(n),void e._updatePath(n,!0);if((r=f(o,a,"LI"))&&(o=r),!o.textContent){if(f(o,a,"UL")||f(o,a,"OL"))return e.modifyBlocks(yn,n);if(f(o,a,"BLOCKQUOTE"))return e.modifyBlocks(mn,n)}for(i=fn(e,o,n.startContainer,n.startOffset),ln(o),Vt(o),S(o,a);i.nodeType===w;){var s,d=i.firstChild;if("A"===i.nodeName&&(!i.textContent||i.textContent===Y)){d=e._doc.createTextNode(""),C(i,d),i=d;break}for(;d&&d.nodeType===F&&!d.data&&(s=d.nextSibling,s&&"BR"!==s.nodeName);)v(d),d=s;if(!d||"BR"===d.nodeName||d.nodeType===F&&!it)break;i=d}n=e._createRange(i,0),e.setSelection(n),e._updatePath(n,!0)},backspace:function(e,t,n){var o=e._root;if(e._removeZWS(),e.saveUndoState(n),n.collapsed)if(Ot(n,o)){t.preventDefault();var r,i=xt(n,o);if(!i)return;if(y(i.parentNode,o),r=l(i,o)){if(!r.isContentEditable)return void v(r);for(k(r,i,n),i=r.parentNode;i!==o&&!i.nextSibling;)i=i.parentNode;i!==o&&(i=i.nextSibling)&&B(i,o),e.setSelection(n)}else if(i){if(f(i,o,"UL")||f(i,o,"OL"))return e.modifyBlocks(yn,n);if(f(i,o,"BLOCKQUOTE"))return e.modifyBlocks(gn,n);e.setSelection(n),e._updatePath(n,!0)}}else e.setSelection(n),setTimeout(function(){Ft(e)},0);else t.preventDefault(),Tt(n,o),Ft(e,n)},"delete":function(e,t,n){var o,r,i,a,s,d,l=e._root;if(e._removeZWS(),e.saveUndoState(n),n.collapsed)if(Rt(n,l)){if(t.preventDefault(),o=xt(n,l),!o)return;if(y(o.parentNode,l),r=c(o,l)){if(!r.isContentEditable)return void v(r);for(k(o,r,n),r=o.parentNode;r!==l&&!r.nextSibling;)r=r.parentNode;r!==l&&(r=r.nextSibling)&&B(r,l),e.setSelection(n),e._updatePath(n,!0)}}else{if(i=n.cloneRange(),Bt(n,e._root),a=n.endContainer,s=n.endOffset,a.nodeType===w&&(d=a.childNodes[s],d&&"IMG"===d.nodeName))return t.preventDefault(),v(d),kt(n),void Ft(e,n);e.setSelection(i),setTimeout(function(){Ft(e)},0)}else t.preventDefault(),Tt(n,l),Ft(e,n)},tab:function(e,t,n){var o,r,i=e._root;if(e._removeZWS(),n.collapsed&&Ot(n,i))for(o=xt(n,i);r=o.parentNode;){if("UL"===r.nodeName||"OL"===r.nodeName){t.preventDefault(),e.modifyBlocks(Sn,n);break}o=r}},"shift-tab":function(e,t,n){var o,r=e._root;e._removeZWS(),n.collapsed&&Ot(n,r)&&(o=n.startContainer,(f(o,r,"UL")||f(o,r,"OL"))&&(t.preventDefault(),e.modifyBlocks(yn,n)))},space:function(e,t,n){var o,r;e._recordUndoState(n),bn(n.startContainer,e._root,e),e._getRangeAndRemoveBookmark(n),o=n.endContainer,r=o.parentNode,n.collapsed&&"A"===r.nodeName&&!o.nextSibling&&n.endOffset===m(o)?n.setStartAfter(r):n.collapsed||(Tt(n,e._root),e._ensureBottomLine(),e.setSelection(n),e._updatePath(n,!0)),e.setSelection(n)},left:function(e){e._removeZWS()},right:function(e){e._removeZWS()}};tt&&ot&&(Mt["meta-left"]=function(e,t){t.preventDefault();var n=dn(e);n&&n.modify&&n.modify("move","backward","lineboundary")},Mt["meta-right"]=function(e,t){t.preventDefault();var n=dn(e);n&&n.modify&&n.modify("move","forward","lineboundary")}),tt||(Mt.pageup=function(e){e.moveCursorToStart()},Mt.pagedown=function(e){e.moveCursorToEnd()}),Mt[lt+"b"]=wt("B"),Mt[lt+"i"]=wt("I"),Mt[lt+"u"]=wt("U"),Mt[lt+"shift-7"]=wt("S"),Mt[lt+"shift-5"]=wt("SUB",{tag:"SUP"}),Mt[lt+"shift-6"]=wt("SUP",{tag:"SUB"}),Mt[lt+"shift-8"]=It("makeUnorderedList"),Mt[lt+"shift-9"]=It("makeOrderedList"),Mt[lt+"["]=It("decreaseQuoteLevel"),Mt[lt+"]"]=It("increaseQuoteLevel"),Mt[lt+"y"]=It("redo"),Mt[lt+"z"]=It("undo"),Mt[lt+"shift-z"]=It("redo");var Ht={1:10,2:13,3:16,4:18,5:24,6:32,7:48},Wt={backgroundColor:{regexp:pt,replace:function(e,t){return _(e,"SPAN",{"class":j,style:"background-color:"+t})}},color:{regexp:pt,replace:function(e,t){return _(e,"SPAN",{"class":Q,style:"color:"+t})}},fontWeight:{regexp:/^bold|^700/i,replace:function(e){return _(e,"B")}},fontStyle:{regexp:/^italic/i,replace:function(e){return _(e,"I")}},fontFamily:{regexp:pt,replace:function(e,t){return _(e,"SPAN",{"class":V,style:"font-family:"+t})}},fontSize:{regexp:pt,replace:function(e,t){return _(e,"SPAN",{"class":$,style:"font-size:"+t})}},textDecoration:{regexp:/^underline/i,replace:function(e){return _(e,"U")}}},zt=function(e){return function(t,n){var o=_(t.ownerDocument,e);return n.replaceChild(o,t),o.appendChild(N(t)),o}},qt=function(e,t){var n,o,r,i,a,s,d=e.style,l=e.ownerDocument;for(n in Wt)o=Wt[n],r=d[n],r&&o.regexp.test(r)&&(s=o.replace(l,r),a||(a=s),i&&i.appendChild(s),i=s,e.style[n]="");return a&&(i.appendChild(N(e)),"SPAN"===e.nodeName?t.replaceChild(a,e):e.appendChild(a)),i||e},Kt={P:qt,SPAN:qt,STRONG:zt("B"),EM:zt("I"),INS:zt("U"),STRIKE:zt("S"),FONT:function(e,t){var n,o,r,i,a,s=e.face,d=e.size,l=e.color,c=e.ownerDocument;return s&&(n=_(c,"SPAN",{"class":"font",style:"font-family:"+s}),a=n,i=n),d&&(o=_(c,"SPAN",{"class":"size",style:"font-size:"+Ht[d]+"px"}),a||(a=o),i&&i.appendChild(o),i=o),l&&/^#?([\dA-F]{3}){1,2}$/i.test(l)&&("#"!==l.charAt(0)&&(l="#"+l),r=_(c,"SPAN",{"class":"colour",style:"color:"+l}),a||(a=r),i&&i.appendChild(r),i=r),a||(a=i=_(c,"SPAN")),t.replaceChild(a,e),i.appendChild(N(e)),i},TT:function(e,t){var n=_(e.ownerDocument,"SPAN",{"class":"font",style:'font-family:menlo,consolas,"courier new",monospace'});return t.replaceChild(n,e),n.appendChild(N(e)),n}},Gt=/^(?: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)|COL(?:GROUP)?|UL)$/,Zt=/^(?:HEAD|META|STYLE)/,jt=new n(null,z|W,function(){return!0}),Qt=function Bn(e,t){var n,o,r,a,s,d,l,c,h,u,f,p,g=e.childNodes;for(n=e;i(n);)n=n.parentNode;for(jt.root=n,o=0,r=g.length;r>o;o+=1)if(a=g[o],s=a.nodeName,d=a.nodeType,l=Kt[s],d===w){if(c=a.childNodes.length,l)a=l(a,e);else{if(Zt.test(s)){e.removeChild(a),o-=1,r-=1;continue}if(!Gt.test(s)&&!i(a)){o-=1,r+=c-1,e.replaceChild(N(a),a);continue}}c&&Bn(a,t||"PRE"===s)}else{if(d===F){if(f=a.data,h=!pt.test(f.charAt(0)),u=!pt.test(f.charAt(f.length-1)),t||!h&&!u)continue;if(h){for(jt.currentNode=a;(p=jt.previousPONode())&&(s=p.nodeName,!("IMG"===s||"#text"===s&&pt.test(p.data)));)if(!i(p)){p=null;break}f=f.replace(/^[ \t\r\n]+/g,p?" ":"")}if(u){for(jt.currentNode=a;(p=jt.nextNode())&&!("IMG"===s||"#text"===s&&pt.test(p.data));)if(!i(p)){p=null;break}f=f.replace(/[ \t\r\n]+$/g,p?" ":"")}if(f){a.data=f;continue}}e.removeChild(a),o-=1,r-=1}return e},Vt=function xn(e){for(var t,n=e.childNodes,o=n.length;o--;)t=n[o],t.nodeType!==w||r(t)?t.nodeType!==F||t.data||e.removeChild(t):(xn(t),i(t)&&!t.firstChild&&e.removeChild(t))},$t=function(e){return e.nodeType===w?"BR"===e.nodeName:pt.test(e.data)},Yt=function(e){for(var t,o=e.parentNode;i(o);)o=o.parentNode;return t=new n(o,W|z,$t),t.currentNode=e,!!t.nextNode()},Xt=function(e,t){var n,o,r,a=e.querySelectorAll("BR"),s=[],d=a.length;for(n=0;d>n;n+=1)s[n]=Yt(a[n]);for(;d--;)o=a[d],r=o.parentNode,r&&(s[d]?i(r)||y(r,t):v(o))},Jt=function(e,t){var n=t.ownerDocument.body;t.setAttribute("style","position:fixed;overflow:hidden;bottom:100%;right:100%;"),n.appendChild(t),e.setData("text/html",t.innerHTML),e.setData("text/plain",t.innerText||t.textContent),n.removeChild(t)},en=function(e){var t=e.clipboardData,n=this.getSelection(),o=this.createElement("div"),r=this._root,i=this;this.saveUndoState(n),at||et||!t?setTimeout(function(){try{i._ensureBottomLine()}catch(e){i.didError(e)}},0):(Bt(n,r),o.appendChild(Tt(n,r)),Jt(t,o),e.preventDefault()),this.setSelection(n)},tn=function(e){var t,n,o,r,i,a,s=e.clipboardData,d=this.getSelection(),l=this.createElement("div"),c=this._root;if(!at&&!et&&s){for(d=d.cloneRange(),t=xt(d,c),n=Lt(d,c),o=t===n?t:c,kt(d),Bt(d,o),r=d.cloneContents(),i=d.commonAncestorContainer,i.nodeType===F&&(i=i.parentNode);i&&i!==o;)a=i.cloneNode(!1),a.appendChild(r),r=a,i=i.parentNode;l.appendChild(r),Jt(s,l),e.preventDefault()}},nn=function(e){var t,n,o,r,i,a=e.clipboardData,s=a&&a.items,d=this.isShiftDown,l=!1,c=!1,h=null,u=this;if(!at&&s){for(e.preventDefault(),t=s.length;t--;){if(n=s[t],o=n.type,!d&&"text/html"===o)return void n.getAsString(function(e){u.insertHTML(e,!0)});"text/plain"===o&&(h=n),!d&&/^image\/.*/.test(o)&&(c=!0)}return void(c?(this.fireEvent("dragover",{dataTransfer:a,preventDefault:function(){l=!0}}),l&&this.fireEvent("drop",{dataTransfer:a})):h&&n.getAsString(function(e){u.insertPlainText(e,!0)}))}if(r=a&&a.types,!at&&r&&(gt.call(r,"text/html")>-1||!ot&&gt.call(r,"text/plain")>-1&&gt.call(r,"text/rtf")<0))return e.preventDefault(),void(!d&&(i=a.getData("text/html"))?this.insertHTML(i,!0):((i=a.getData("text/plain"))||(i=a.getData("text/uri-list")))&&this.insertPlainText(i,!0));this._awaitingPaste=!0;var f=this._doc.body,p=this.getSelection(),g=p.startContainer,m=p.startOffset,C=p.endContainer,N=p.endOffset,_=this.createElement("DIV",{contenteditable:"true",style:"position:fixed; overflow:hidden; top:0; right:100%; width:1px; height:1px;"});f.appendChild(_),p.selectNodeContents(_),this.setSelection(p),setTimeout(function(){try{u._awaitingPaste=!1;for(var e,t,n="",o=_;_=o;)o=_.nextSibling,v(_),e=_.firstChild,e&&e===_.lastChild&&"DIV"===e.nodeName&&(_=e),n+=_.innerHTML;t=u._createRange(g,m,C,N),u.setSelection(t),n&&u.insertHTML(n,!0)}catch(r){u.didError(r)}},0)},on=function(e){for(var t=e.dataTransfer.types,n=t.length,o=!1,r=!1;n--;)switch(t[n]){case"text/plain":o=!0;break;case"text/html":r=!0;break;default:return}(r||o)&&this.saveUndoState()},rn=[],an=O.prototype;an.setConfig=function(e){return e=A({blockTag:"DIV",blockAttributes:null,tagAttributes:{blockquote:null,ul:null,ol:null,li:null,a:null},leafNodeNames:Ct,undo:{documentSizeThreshold:-1,undoLimit:-1}},e,!0),e.blockTag=e.blockTag.toUpperCase(),this._config=e,this},an.createElement=function(e,t,n){return _(this._doc,e,t,n)},an.createDefaultBlock=function(e){var t=this._config;return S(this.createElement(t.blockTag,t.blockAttributes,e),this._root)},an.didError=function(e){console.log(e)},an.getDocument=function(){return this._doc},an.getRoot=function(){return this._root},an.modifyDocument=function(e){this._ignoreAllChanges=!0,this._mutation&&this._mutation.disconnect(),e(),this._ignoreAllChanges=!1,this._mutation&&this._mutation.observe(this._root,{childList:!0,attributes:!0,characterData:!0,subtree:!0})};var sn={pathChange:1,select:1,input:1,undoStateChange:1};an.fireEvent=function(e,t){var n,o,r,i=this._events[e];if(/^(?:focus|blur)/.test(e))if(n=p(this._root,this._doc.activeElement),"focus"===e){if(!n||this._isFocused)return this;this._isFocused=!0}else{if(n||!this._isFocused)return this;this._isFocused=!1}if(i)for(t||(t={}),t.type!==e&&(t.type=e),i=i.slice(),o=i.length;o--;){r=i[o];try{r.handleEvent?r.handleEvent(t):r.call(this,t)}catch(a){a.details="Squire: fireEvent error. Event type: "+e,this.didError(a)}}return this},an.destroy=function(){var e,t=rn.length,n=this._events;for(e in n)this.removeEventListener(e);for(this._mutation&&this._mutation.disconnect();t--;)rn[t]===this&&rn.splice(t,1);this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0},an.handleEvent=function(e){this.fireEvent(e.type,e)},an.addEventListener=function(e,t){var n=this._events[e],o=this._root;return t?(n||(n=this._events[e]=[],sn[e]||("selectionchange"===e&&(o=this._doc),o.addEventListener(e,this,!0))),n.push(t),this):(this.didError({name:"Squire: addEventListener with null or undefined fn",message:"Event type: "+e}),this)},an.removeEventListener=function(e,t){var n,o=this._events[e],r=this._root;if(o){if(t)for(n=o.length;n--;)o[n]===t&&o.splice(n,1);else o.length=0;o.length||(delete this._events[e],sn[e]||("selectionchange"===e&&(r=this._doc),r.removeEventListener(e,this,!0)))}return this},an._createRange=function(e,t,n,o){if(e instanceof this._win.Range)return e.cloneRange();var r=this._doc.createRange();return r.setStart(e,t),n?r.setEnd(n,o):r.setEnd(e,t),r},an.getCursorPosition=function(e){if(!e&&!(e=this.getSelection())||!e.getBoundingClientRect)return null;var t,n,o=e.getBoundingClientRect();return o&&!o.top&&(this._ignoreChange=!0,t=this._doc.createElement("SPAN"),t.textContent=Y,St(e,t),o=t.getBoundingClientRect(),n=t.parentNode,n.removeChild(t),E(n,e)),o},an._moveCursorTo=function(e){var t=this._root,n=this._createRange(t,e?0:t.childNodes.length);return kt(n),this.setSelection(n),this},an.moveCursorToStart=function(){return this._moveCursorTo(!0)},an.moveCursorToEnd=function(){return this._moveCursorTo(!1)};var dn=function(e){return e._win.getSelection()||null};an.setSelection=function(e){if(e)if(this._lastSelection=e,this._isFocused)if(nt&&!this._restoreSelection)R.call(this),this.blur(),this.focus();else{et&&this._win.focus();var t=dn(this);t&&(t.removeAllRanges(),t.addRange(e))}else R.call(this);return this},an.getSelection=function(){var e,t,n,o=dn(this),i=this._root;return o&&o.rangeCount&&(e=o.getRangeAt(0).cloneRange(),t=e.startContainer,n=e.endContainer,t&&r(t)&&e.setStartBefore(t),n&&r(n)&&e.setEndBefore(n)),e&&p(i,e.commonAncestorContainer)?this._lastSelection=e:e=this._lastSelection,e||(e=this._createRange(i.firstChild,0)),e},an.getSelectedText=function(){var e,t=this.getSelection(),o=new n(t.commonAncestorContainer,z|W,function(e){return Et(t,e,!0)}),r=t.startContainer,a=t.endContainer,s=o.currentNode=r,d="",l=!1;for(o.filter(s)||(s=o.nextNode());s;)s.nodeType===F?(e=s.data,e&&/\S/.test(e)&&(s===a&&(e=e.slice(0,t.endOffset)),s===r&&(e=e.slice(t.startOffset)),d+=e,l=!0)):("BR"===s.nodeName||l&&!i(s))&&(d+="\n",l=!1),s=o.nextNode();return d},an.getPath=function(){return this._path};var ln=function(e,t){for(var o,r,a,s=new n(e,z,function(){return!0},!1);r=s.nextNode();)for(;(a=r.data.indexOf(Y))>-1&&(!t||r.parentNode!==t);){if(1===r.length){do o=r.parentNode,o.removeChild(r),r=o,s.currentNode=o;while(i(r)&&!m(r));break}r.deleteData(a,1)}};an._didAddZWS=function(){this._hasZWS=!0},an._removeZWS=function(){this._hasZWS&&(ln(this._root),this._hasZWS=!1)},an._updatePath=function(e,t){var n,o=e.startContainer,r=e.endContainer;(t||o!==this._lastAnchorNode||r!==this._lastFocusNode)&&(this._lastAnchorNode=o,this._lastFocusNode=r,n=o&&r?o===r?g(r,this._root):"(selection)":"",this._path!==n&&(this._path=n,this.fireEvent("pathChange",{path:n}))),e.collapsed||this.fireEvent("select")},an._updatePathOnEvent=function(){var e=this;e._willUpdatePath||(e._willUpdatePath=!0,setTimeout(function(){e._willUpdatePath=!1,e._updatePath(e.getSelection())},0))},an.focus=function(){return this._root.focus(),dt&&this.fireEvent("focus"),this},an.blur=function(){return this._root.blur(),dt&&this.fireEvent("blur"),this};var cn="squire-selection-start",hn="squire-selection-end";an._saveRangeToBookmark=function(e){var t,n=this.createElement("INPUT",{id:cn,type:"hidden"}),o=this.createElement("INPUT",{id:hn,type:"hidden"});St(e,n),e.collapse(!1),St(e,o),n.compareDocumentPosition(o)&I&&(n.id=hn,o.id=cn,t=n,n=o,o=t),e.setStartAfter(n),e.setEndBefore(o)},an._getRangeAndRemoveBookmark=function(e){var t=this._root,n=t.querySelector("#"+cn),o=t.querySelector("#"+hn);if(n&&o){var r=n.parentNode,i=o.parentNode,a=gt.call(r.childNodes,n),s=gt.call(i.childNodes,o);r===i&&(s-=1),v(n),v(o),e||(e=this._doc.createRange()),e.setStart(r,a),e.setEnd(i,s),E(r,e),r!==i&&E(i,e),e.collapsed&&(r=e.startContainer,r.nodeType===F&&(i=r.childNodes[e.startOffset],i&&i.nodeType===F||(i=r.childNodes[e.startOffset-1]),i&&i.nodeType===F&&(e.setStart(i,0),e.collapse(!0))))}return e||null},an._keyUpDetectChange=function(e){var t=e.keyCode;e.ctrlKey||e.metaKey||e.altKey||!(16>t||t>20)||!(33>t||t>45)||this._docWasChanged()},an._docWasChanged=function(){if(!this._ignoreAllChanges){if(ft&&this._ignoreChange)return void(this._ignoreChange=!1);this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),this.fireEvent("input")}},an._recordUndoState=function(e){if(!this._isInUndoState){var t,n=this._undoIndex+=1,o=this._undoStack,r=this._config.undo,i=r.documentSizeThreshold,a=r.undoLimit;n<this._undoStackLength&&(o.length=this._undoStackLength=n),e&&this._saveRangeToBookmark(e),t=this._getHTML(),i>-1&&2*t.length>i&&a>-1&&n>a&&(o.splice(0,n-a),n=this._undoIndex=a,this._undoStackLength=a),o[n]=t,this._undoStackLength+=1,this._isInUndoState=!0}},an.saveUndoState=function(e){return e===t&&(e=this.getSelection()),this._isInUndoState||(this._recordUndoState(e),this._getRangeAndRemoveBookmark(e)),this},an.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},an.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},an.hasFormat=function(e,t,o){if(e=e.toUpperCase(),t||(t={}),!o&&!(o=this.getSelection()))return!1;!o.collapsed&&o.startContainer.nodeType===F&&o.startOffset===o.startContainer.length&&o.startContainer.nextSibling&&o.setStartBefore(o.startContainer.nextSibling),!o.collapsed&&o.endContainer.nodeType===F&&0===o.endOffset&&o.endContainer.previousSibling&&o.setEndAfter(o.endContainer.previousSibling);var r,i,a=this._root,s=o.commonAncestorContainer;if(f(s,a,e,t))return!0;if(s.nodeType===F)return!1;r=new n(s,z,function(e){return Et(o,e,!0)},!1);for(var d=!1;i=r.nextNode();){if(!f(i,a,e,t))return!1;d=!0}return d},an.getFontInfo=function(e){var n,o,r,i={color:t,backgroundColor:t,family:t,size:t},a=0;if(!e&&!(e=this.getSelection()))return i;if(n=e.commonAncestorContainer,e.collapsed||n.nodeType===F)for(n.nodeType===F&&(n=n.parentNode);4>a&&n;)(o=n.style)&&(!i.color&&(r=o.color)&&(i.color=r,a+=1),!i.backgroundColor&&(r=o.backgroundColor)&&(i.backgroundColor=r,a+=1),!i.family&&(r=o.fontFamily)&&(i.family=r,a+=1),!i.size&&(r=o.fontSize)&&(i.size=r,a+=1)),n=n.parentNode;return i},an._addFormat=function(e,t,o){var r,a,s,d,l,c,h,u,p,g=this._root;if(o.collapsed){for(r=S(this.createElement(e,t),g),St(o,r),o.setStart(r.firstChild,r.firstChild.length),o.collapse(!0),p=r;i(p);)p=p.parentNode;ln(p,r)}else{if(a=new n(o.commonAncestorContainer,z|W,function(e){return(e.nodeType===F||"BR"===e.nodeName||"IMG"===e.nodeName)&&Et(o,e,!0)},!1),s=o.startContainer,l=o.startOffset,d=o.endContainer,c=o.endOffset,a.currentNode=s,a.filter(s)||(s=a.nextNode(),l=0),!s)return o;do h=a.currentNode,u=!f(h,g,e,t),u&&(h===d&&h.length>c&&h.splitText(c),h===s&&l&&(h=h.splitText(l),d===s&&(d=h,c-=l),s=h,l=0),r=this.createElement(e,t),C(h,r),r.appendChild(h));while(a.nextNode());d.nodeType!==F&&(h.nodeType===F?(d=h,c=h.length):(d=h.parentNode,c=1)),o=this._createRange(s,l,d,c)}return o},an._removeFormat=function(e,t,n,o){this._saveRangeToBookmark(n);var r,a=this._doc;n.collapsed&&(ht?(r=a.createTextNode(Y),this._didAddZWS()):r=a.createTextNode(""),St(n,r));for(var s=n.commonAncestorContainer;i(s);)s=s.parentNode;var d=n.startContainer,l=n.startOffset,c=n.endContainer,h=n.endOffset,f=[],p=function(e,t){if(!Et(n,e,!1)){var o,r,i=e.nodeType===F;if(!Et(n,e,!0))return void("INPUT"===e.nodeName||i&&!e.data||f.push([t,e]));if(i)e===c&&h!==e.length&&f.push([t,e.splitText(h)]),e===d&&l&&(e.splitText(l),f.push([t,e]));else for(o=e.firstChild;o;o=r)r=o.nextSibling,p(o,t)}},g=Array.prototype.filter.call(s.getElementsByTagName(e),function(o){return Et(n,o,!0)&&u(o,e,t)});return o||g.forEach(function(e){p(e,e)}),f.forEach(function(e){var t=e[0].cloneNode(!1),n=e[1];C(n,t),t.appendChild(n)}),g.forEach(function(e){C(e,N(e))}),this._getRangeAndRemoveBookmark(n),r&&n.collapse(!1),E(s,n),n},an.changeFormat=function(e,t,n,o){return n||(n=this.getSelection())?(this.saveUndoState(n),t&&(n=this._removeFormat(t.tag.toUpperCase(),t.attributes||{},n,o)),e&&(n=this._addFormat(e.tag.toUpperCase(),e.attributes||{},n)),this.setSelection(n),this._updatePath(n,!0),ft||this._docWasChanged(),this):this};var un={DT:"DD",DD:"DT",LI:"LI"},fn=function(e,t,n,o){var r=un[t.nodeName],i=null,a=T(n,o,t.parentNode,e._root),s=e._config;return r||(r=s.blockTag,i=s.blockAttributes),u(a,r,i)||(t=_(a.ownerDocument,r,i),a.dir&&(t.dir=a.dir),C(a,t),t.appendChild(N(a)),a=t),a};an.forEachBlock=function(e,t,n){if(!n&&!(n=this.getSelection()))return this;t&&this.saveUndoState(n);var o=this._root,r=xt(n,o),i=Lt(n,o);if(r&&i)do if(e(r)||r===i)break;while(r=c(r,o));return t&&(this.setSelection(n),this._updatePath(n,!0),ft||this._docWasChanged()),this},an.modifyBlocks=function(e,t){if(!t&&!(t=this.getSelection()))return this;this._isInUndoState?this._saveRangeToBookmark(t):this._recordUndoState(t);var n,o=this._root;return Dt(t,o),Bt(t,o),n=yt(t,o,o),St(t,e.call(this,n)),t.endOffset<t.endContainer.childNodes.length&&B(t.endContainer.childNodes[t.endOffset],o),B(t.startContainer.childNodes[t.startOffset],o),this._getRangeAndRemoveBookmark(t),this.setSelection(t),this._updatePath(t,!0),ft||this._docWasChanged(),this};var pn=function(e){return this.createElement("BLOCKQUOTE",this._config.tagAttributes.blockquote,[e])},gn=function(e){var t=this._root,n=e.querySelectorAll("blockquote");return Array.prototype.filter.call(n,function(e){return!f(e.parentNode,t,"BLOCKQUOTE")}).forEach(function(e){C(e,N(e))}),e},mn=function(){return this.createDefaultBlock([this.createElement("INPUT",{id:cn,type:"hidden"}),this.createElement("INPUT",{id:hn,type:"hidden"})])},vn=function(e,t,n){for(var o,r,i,a,s=d(t,e._root),l=e._config.tagAttributes,c=l[n.toLowerCase()],h=l.li;o=s.nextNode();)"LI"===o.parentNode.nodeName&&(o=o.parentNode,s.currentNode=o.lastChild),"LI"!==o.nodeName?(a=e.createElement("LI",h),o.dir&&(a.dir=o.dir),(i=o.previousSibling)&&i.nodeName===n?(i.appendChild(a),v(o)):C(o,e.createElement(n,c,[a])),a.appendChild(N(o)),s.currentNode=a):(o=o.parentNode,r=o.nodeName,r!==n&&/^[OU]L$/.test(r)&&C(o,e.createElement(n,c,[N(o)])))},Cn=function(e){return vn(this,e,"UL"),e},Nn=function(e){return vn(this,e,"OL"),e},_n=function(e){var t,n,o,r,i,s=e.querySelectorAll("UL, OL"),d=e.querySelectorAll("LI"),l=this._root;for(t=0,n=s.length;n>t;t+=1)o=s[t],r=N(o),y(r,l),C(o,r);for(t=0,n=d.length;n>t;t+=1)i=d[t],a(i)?C(i,this.createDefaultBlock([N(i)])):(y(i,l),C(i,N(i)));return e},Sn=function(e){var t,n,o,r,i,a,d=e.querySelectorAll("LI"),l=this._config.tagAttributes;for(t=0,n=d.length;n>t;t+=1)o=d[t],s(o.firstChild)||(r=o.parentNode.nodeName,i=o.previousSibling,i&&(i=i.lastChild)&&i.nodeName===r||(a=l[r.toLowerCase()],i=this.createElement(r,a),C(o,i)),i.appendChild(o));return e},yn=function(e){var t=this._root,n=e.querySelectorAll("LI");return Array.prototype.filter.call(n,function(e){return!s(e.firstChild)}).forEach(function(n){var o,r=n.parentNode,i=r.parentNode,a=n.firstChild,d=a;if(n.previousSibling&&(r=T(r,n,i,t)),/^[OU]L$/.test(i.nodeName))i.insertBefore(n,r),r.firstChild||i.removeChild(r);else for(;d&&(o=d.nextSibling,!s(d));)i.insertBefore(d,r),d=o;for("LI"===i.nodeName&&a.previousSibling&&T(i,a,i.parentNode,t);n!==e&&!n.childNodes.length;)r=n.parentNode,r.removeChild(n),n=r},this),y(e,t),e};an._ensureBottomLine=function(){var e=this._root,t=e.lastElementChild;t&&t.nodeName===this._config.blockTag&&a(t)||e.appendChild(this.createDefaultBlock())},an.setKeyHandler=function(e,t){return this._keyHandlers[e]=t,this},an._getHTML=function(){return this._root.innerHTML},an._setHTML=function(e){var t=this._root,n=t;n.innerHTML=e;do S(n,t);while(n=c(n,t));this._ignoreChange=!0},an.getHTML=function(e){var t,n,o,r,i,a,s=[];if(e&&(a=this.getSelection())&&this._saveRangeToBookmark(a),ct)for(t=this._root,n=t;n=c(n,t);)n.textContent||n.querySelector("BR")||(o=this.createElement("BR"),n.appendChild(o),s.push(o));if(r=this._getHTML().replace(/\u200B/g,""),ct)for(i=s.length;i--;)v(s[i]);return a&&this._getRangeAndRemoveBookmark(a),r},an.setHTML=function(e){var t,n=this._doc.createDocumentFragment(),o=this.createElement("DIV"),r=this._root;o.innerHTML=e,n.appendChild(N(o)),Qt(n),Xt(n,r),y(n,r);for(var i=n;i=c(i,r);)S(i,r);for(this._ignoreChange=!0;t=r.lastChild;)r.removeChild(t);r.appendChild(n),S(r,r),this._undoIndex=-1,this._undoStack.length=0,this._undoStackLength=0,this._isInUndoState=!1;var a=this._getRangeAndRemoveBookmark()||this._createRange(r.firstChild,0);return this.saveUndoState(a),this._lastSelection=a,R.call(this),this._updatePath(a,!0),this},an.insertElement=function(e,t){if(t||(t=this.getSelection()),t.collapse(!0),i(e))St(t,e),t.setStartAfter(e);else{for(var n,o,r=this._root,a=xt(t,r)||r;a!==r&&!a.nextSibling;)a=a.parentNode;a!==r&&(n=a.parentNode,o=T(n,a.nextSibling,r,r)),o?r.insertBefore(e,o):(r.appendChild(e),o=this.createDefaultBlock(),r.appendChild(o)),t.setStart(o,0),t.setEnd(o,0),kt(t)}return this.focus(),this.setSelection(t),this._updatePath(t),ft||this._docWasChanged(),this},an.insertImage=function(e,t){var n=this.createElement("IMG",A({src:e},t,!0));return this.insertElement(n),n};var Tn=/\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,bn=function(e,t,o){for(var r,i,a,s,d,l,c,h=e.ownerDocument,u=new n(e,z,function(e){return!f(e,t,"A")},!1),p=o._config.tagAttributes.a;r=u.nextNode();)for(i=r.data,a=r.parentNode;s=Tn.exec(i);)d=s.index,l=d+s[0].length,d&&(c=h.createTextNode(i.slice(0,d)),a.insertBefore(c,r)),c=o.createElement("A",A({href:s[1]?/^(?:ht|f)tps?:/.test(s[1])?s[1]:"http://"+s[1]:"mailto:"+s[2]},p,!1)),c.textContent=i.slice(d,l),a.insertBefore(c,r),r.data=i=i.slice(l)};an.insertHTML=function(e,t){var n,o,r,i,a,s,d,l=this.getSelection(),h=this._doc;"undefined"!=typeof DOMPurify&&DOMPurify.isSupported?(i=DOMPurify.sanitize(e,{WHOLE_DOCUMENT:!1,RETURN_DOM:!0,RETURN_DOM_FRAGMENT:!0}),i=h.importNode(i,!0)):(t&&(n=e.indexOf("<!--StartFragment-->"),o=e.lastIndexOf("<!--EndFragment-->"),n>-1&&o>-1&&(e=e.slice(n+20,o))),r=this.createElement("DIV"),r.innerHTML=e,i=h.createDocumentFragment(),i.appendChild(N(r))),this.saveUndoState(l);try{for(a=this._root,s=i,d={fragment:i,preventDefault:function(){this.defaultPrevented=!0},defaultPrevented:!1},bn(i,i,this),Qt(i),Xt(i,null),Vt(i),i.normalize();s=c(s,i);)S(s,null);t&&this.fireEvent("willPaste",d),d.defaultPrevented||(bt(l,d.fragment,a),ft||this._docWasChanged(),l.collapse(!1),this._ensureBottomLine()),this.setSelection(l),this._updatePath(l,!0),t&&this.focus()}catch(u){this.didError(u)}return this};var En=function(e){return e.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;").split('"').join("&quot;")};an.insertPlainText=function(e,t){var n,o,r,i,a=e.split("\n"),s=this._config,d=s.blockTag,l=s.blockAttributes,c="</"+d+">",h="<"+d;for(n in l)h+=" "+n+'="'+En(l[n])+'"';for(h+=">",o=0,r=a.length;r>o;o+=1)i=a[o],i=En(i).replace(/ (?= )/g,"&nbsp;"),o&&r>o+1&&(i=h+(i||"<BR>")+c),a[o]=i;return this.insertHTML(a.join(""),t)};var kn=function(e,t,n){return function(){return this[e](t,n),this.focus()}};an.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},an.bold=kn("changeFormat",{tag:"B"}),an.italic=kn("changeFormat",{tag:"I"}),an.underline=kn("changeFormat",{tag:"U"}),an.strikethrough=kn("changeFormat",{tag:"S"}),an.subscript=kn("changeFormat",{tag:"SUB"},{tag:"SUP"}),an.superscript=kn("changeFormat",{tag:"SUP"},{tag:"SUB"}),an.removeBold=kn("changeFormat",null,{tag:"B"}),an.removeItalic=kn("changeFormat",null,{tag:"I"}),an.removeUnderline=kn("changeFormat",null,{tag:"U"}),an.removeStrikethrough=kn("changeFormat",null,{tag:"S"}),an.removeSubscript=kn("changeFormat",null,{tag:"SUB"}),an.removeSuperscript=kn("changeFormat",null,{tag:"SUP"}),an.makeLink=function(e,t){var n=this.getSelection();if(n.collapsed){var o=e.indexOf(":")+1;if(o)for(;"/"===e[o];)o+=1;St(n,this._doc.createTextNode(e.slice(o)))}return t=A(A({href:e},t,!0),this._config.tagAttributes.a,!1),this.changeFormat({tag:"A",attributes:t},{tag:"A"},n),this.focus()},an.removeLink=function(){return this.changeFormat(null,{tag:"A"},this.getSelection(),!0),this.focus()},an.setFontFace=function(e){return this.changeFormat(e?{tag:"SPAN",attributes:{"class":"font",style:"font-family: "+e+", sans-serif;"}}:null,{tag:"SPAN",attributes:{"class":"font"}}),this.focus()},an.setFontSize=function(e){return this.changeFormat(e?{tag:"SPAN",attributes:{"class":"size",style:"font-size: "+("number"==typeof e?e+"px":e)}}:null,{tag:"SPAN",attributes:{"class":"size"}}),this.focus()},an.setTextColour=function(e){return this.changeFormat(e?{tag:"SPAN",attributes:{"class":"colour",style:"color:"+e}}:null,{tag:"SPAN",attributes:{"class":"colour"}}),this.focus()},an.setHighlightColour=function(e){return this.changeFormat(e?{tag:"SPAN",attributes:{"class":"highlight",style:"background-color:"+e}}:e,{tag:"SPAN",attributes:{"class":"highlight"}}),this.focus()},an.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()},an.setTextDirection=function(e){return this.forEachBlock(function(t){t.dir=e},!0),this.focus()},an.removeAllFormatting=function(e){if(!e&&!(e=this.getSelection())||e.collapsed)return this;for(var t=this._root,n=e.commonAncestorContainer;n&&!a(n);)n=n.parentNode;if(n||(Dt(e,t),n=t),n.nodeType===F)return this;this.saveUndoState(e),Bt(e,n);for(var o,r,i=n.ownerDocument,s=e.startContainer,d=e.startOffset,l=e.endContainer,c=e.endOffset,h=i.createDocumentFragment(),u=i.createDocumentFragment(),f=T(l,c,n,t),p=T(s,d,n,t);p!==f;)o=p.nextSibling,h.appendChild(p),p=o;return P(this,h,u),u.normalize(),p=u.firstChild,o=u.lastChild,r=n.childNodes,p?(n.insertBefore(u,f),d=gt.call(r,p),c=gt.call(r,o)+1):(d=gt.call(r,f),c=d),e.setStart(n,d),e.setEnd(n,c),E(n,e),kt(e),this.setSelection(e),this._updatePath(e,!0),this.focus()},an.increaseQuoteLevel=kn("modifyBlocks",pn),an.decreaseQuoteLevel=kn("modifyBlocks",gn),an.makeUnorderedList=kn("modifyBlocks",Cn),an.makeOrderedList=kn("modifyBlocks",Nn),an.removeList=kn("modifyBlocks",_n),an.increaseListLevel=kn("modifyBlocks",Sn),an.decreaseListLevel=kn("modifyBlocks",yn),O.getNodeBefore=Nt,O.getNodeAfter=_t,O.insertNodeInRange=St,O.extractContentsOfRange=yt,O.deleteContentsOfRange=Tt,O.insertTreeFragmentIntoRange=bt,O.isNodeContainedInRange=Et,O.moveRangeBoundariesDownTree=kt,O.moveRangeBoundariesUpTree=Bt,O.getStartBlockOfRange=xt,O.getEndBlockOfRange=Lt,O.contentWalker=At,O.rangeDoesStartAtBlockBoundary=Ot,O.rangeDoesEndAtBlockBoundary=Rt,O.expandRangeToBlockBoundaries=Dt,O.onPaste=nn,O.addLinks=bn,O.splitBlock=fn,O.startSelectionId=cn,O.endSelectionId=hn,"object"==typeof exports?module.exports=O:"function"==typeof define&&define.amd?define(function(){return O}):(X.Squire=O,top!==X&&"true"===e.documentElement.getAttribute("data-squireinit")&&(X.editor=new O(e),X.onEditorLoad&&(X.onEditorLoad(X.editor),X.onEditorLoad=null)))}(document);
\ No newline at end of file
+!function(e,t){"use strict";function n(e,t,n){this.root=this.currentNode=e,this.nodeType=t,this.filter=n}function o(e,t){for(var n=e.length;n--;)if(!t(e[n]))return!1;return!0}function i(e){return e.nodeType===w&&!!_e[e.nodeName]}function r(e){switch(e.nodeType){case F:return Se;case w:case H:if(pe&&be.has(e))return be.get(e);break;default:return Ne}var t;return t=o(e.childNodes,a)?Ce.test(e.nodeName)?Se:ye:Te,pe&&be.set(e,t),t}function a(e){return r(e)===Se}function s(e){return r(e)===ye}function d(e){return r(e)===Te}function l(e,t){var o=new n(t,W,s);return o.currentNode=e,o}function c(e,t){return e=l(e,t).previousNode(),e!==t?e:null}function h(e,t){return e=l(e,t).nextNode(),e!==t?e:null}function u(e,t){return!i(e)&&e.nodeType===t.nodeType&&e.nodeName===t.nodeName&&"A"!==e.nodeName&&e.className===t.className&&(!e.style&&!t.style||e.style.cssText===t.style.cssText)}function f(e,t,n){if(e.nodeName!==t)return!1;for(var o in n)if(e.getAttribute(o)!==n[o])return!1;return!0}function p(e,t,n,o){for(;e&&e!==t;){if(f(e,n,o))return e;e=e.parentNode}return null}function g(e,t){for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function m(e,t){var n,o,i,r,a="";return e&&e!==t&&(a=m(e.parentNode,t),e.nodeType===w&&(a+=(a?">":"")+e.nodeName,(n=e.id)&&(a+="#"+n),(o=e.className.trim())&&(i=o.split(/\s\s*/),i.sort(),a+=".",a+=i.join(".")),(r=e.dir)&&(a+="[dir="+r+"]"),i&&(me.call(i,j)>-1&&(a+="[backgroundColor="+e.style.backgroundColor.replace(/ /g,"")+"]"),me.call(i,Q)>-1&&(a+="[color="+e.style.color.replace(/ /g,"")+"]"),me.call(i,V)>-1&&(a+="[fontFamily="+e.style.fontFamily.replace(/ /g,"")+"]"),me.call(i,$)>-1&&(a+="[fontSize="+e.style.fontSize+"]")))),a}function v(e){var t=e.nodeType;return t===w?e.childNodes.length:e.length||0}function C(e){var t=e.parentNode;return t&&t.removeChild(e),e}function _(e,t){var n=e.parentNode;n&&n.replaceChild(t,e)}function N(e){for(var t=e.ownerDocument.createDocumentFragment(),n=e.childNodes,o=n?n.length:0;o--;)t.appendChild(e.firstChild);return t}function S(e,n,o,i){var r,a,s,d,l=e.createElement(n);if(o instanceof Array&&(i=o,o=null),o)for(r in o)a=o[r],a!==t&&l.setAttribute(r,o[r]);if(i)for(s=0,d=i.length;s<d;s+=1)l.appendChild(i[s]);return l}function y(e,t){var n,o,r=t.__squire__,s=e.ownerDocument,d=e;if(e===t&&((o=e.firstChild)&&"BR"!==o.nodeName||(n=r.createDefaultBlock(),o?e.replaceChild(n,o):e.appendChild(n),e=n,n=null)),e.nodeType===F)return d;if(a(e)){for(o=e.firstChild;he&&o&&o.nodeType===F&&!o.data;)e.removeChild(o),o=e.firstChild;o||(he?(n=s.createTextNode(Y),r._didAddZWS()):n=s.createTextNode(""))}else if(ce){for(;e.nodeType!==F&&!i(e);){if(o=e.firstChild,!o){n=s.createTextNode("");break}e=o}e.nodeType===F?/^ +$/.test(e.data)&&(e.data=""):i(e)&&e.parentNode.insertBefore(s.createTextNode(""),e)}else if(!e.querySelector("BR"))for(n=S(s,"BR");(o=e.lastElementChild)&&!a(o);)e=o;if(n)try{e.appendChild(n)}catch(t){r.didError({name:"Squire: fixCursor – "+t,message:"Parent: "+e.nodeName+"/"+e.innerHTML+" appendChild: "+n.nodeName})}return d}function T(e,t){var n,o,i,r,s=e.childNodes,l=e.ownerDocument,c=null,h=t.__squire__._config;for(n=0,o=s.length;n<o;n+=1)i=s[n],r="BR"===i.nodeName,!r&&a(i)?(c||(c=S(l,h.blockTag,h.blockAttributes)),c.appendChild(i),n-=1,o-=1):(r||c)&&(c||(c=S(l,h.blockTag,h.blockAttributes)),y(c,t),r?e.replaceChild(c,i):(e.insertBefore(c,i),n+=1,o+=1),c=null),d(i)&&T(i,t);return c&&e.appendChild(y(c,t)),e}function b(e,t,n,o){var i,r,a,s=e.nodeType;if(s===F&&e!==n)return b(e.parentNode,e.splitText(t),n,o);if(s===w){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;)a=t.nextSibling,r.appendChild(t),t=a;return"OL"===e.nodeName&&p(e,o,"BLOCKQUOTE")&&(r.start=(+e.start||1)+e.childNodes.length-1),y(e,o),y(r,o),(a=e.nextSibling)?i.insertBefore(r,a):i.appendChild(r),b(i,r,n,o)}return t}function E(e,t){for(var n,o,i,r=e.childNodes,s=r.length,d=[];s--;)if(n=r[s],o=s&&r[s-1],s&&a(n)&&u(n,o)&&!_e[n.nodeName])t.startContainer===n&&(t.startContainer=o,t.startOffset+=v(o)),t.endContainer===n&&(t.endContainer=o,t.endOffset+=v(o)),t.startContainer===e&&(t.startOffset>s?t.startOffset-=1:t.startOffset===s&&(t.startContainer=o,t.startOffset=v(o))),t.endContainer===e&&(t.endOffset>s?t.endOffset-=1:t.endOffset===s&&(t.endContainer=o,t.endOffset=v(o))),C(n),n.nodeType===F?o.appendData(n.data):d.push(N(n));else if(n.nodeType===w){for(i=d.length;i--;)n.appendChild(d.pop());E(n,t)}}function k(e,t){if(e.nodeType===F&&(e=e.parentNode),e.nodeType===w){var n={startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset};E(e,n),t.setStart(n.startContainer,n.startOffset),t.setEnd(n.endContainer,n.endOffset)}}function B(e,t,n){for(var o,i,r=t;1===r.parentNode.childNodes.length;)r=r.parentNode;C(r),i=e.childNodes.length,o=e.lastChild,o&&"BR"===o.nodeName&&(e.removeChild(o),i-=1),e.appendChild(N(t)),n.setStart(e,i),n.collapse(!0),k(e,n),re&&(o=e.lastChild)&&"BR"===o.nodeName&&e.removeChild(o)}function x(e,t){var n,o,i=e.previousSibling,r=e.firstChild,a=e.ownerDocument,s="LI"===e.nodeName;if(!s||r&&/^[OU]L$/.test(r.nodeName))if(i&&u(i,e)){if(!d(i)){if(!s)return;o=S(a,"DIV"),o.appendChild(N(i)),i.appendChild(o)}C(e),n=!d(e),i.appendChild(N(e)),n&&T(i,t),r&&x(r,t)}else s&&(i=S(a,"DIV"),e.insertBefore(i,r),y(i,t))}function L(e){this.isShiftDown=e.shiftKey}function A(e,t,n){var o,i;if(e||(e={}),t)for(o in t)!n&&o in e||(i=t[o],e[o]=i&&i.constructor===Object?A(e[o],i,n):i);return e}function O(e,t){e.nodeType===M&&(e=e.body);var n,o=e.ownerDocument,i=o.defaultView;this._win=i,this._doc=o,this._root=e,this._events={},this._isFocused=!1,this._lastSelection=null,ue&&this.addEventListener("beforedeactivate",this.getSelection),this._hasZWS=!1,this._lastAnchorNode=null,this._lastFocusNode=null,this._path="",this._willUpdatePath=!1,"onselectionchange"in o?this.addEventListener("selectionchange",this._updatePathOnEvent):(this.addEventListener("keyup",this._updatePathOnEvent),this.addEventListener("mouseup",this._updatePathOnEvent)),this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0,this._isInUndoState=!1,this._ignoreChange=!1,this._ignoreAllChanges=!1,fe?(n=new MutationObserver(this._docWasChanged.bind(this)),n.observe(e,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),this._mutation=n):this.addEventListener("keyup",this._keyUpDetectChange),this._restoreSelection=!1,this.addEventListener("blur",D),this.addEventListener("mousedown",R),this.addEventListener("touchstart",R),this.addEventListener("focus",U),this._awaitingPaste=!1,this.addEventListener(ie?"beforecut":"cut",at),this.addEventListener("copy",st),this.addEventListener("keydown",L),this.addEventListener("keyup",L),this.addEventListener(ie?"beforepaste":"paste",dt),this.addEventListener("drop",lt),this.addEventListener(re?"keypress":"keydown",We),this._keyHandlers=Object.create(Ge),this.setConfig(t),ie&&(i.Text.prototype.splitText=function(e){var t=this.ownerDocument.createTextNode(this.data.slice(e)),n=this.nextSibling,o=this.parentNode,i=this.length-e;return n?o.insertBefore(t,n):o.appendChild(t),i&&this.deleteData(e,i),t}),e.setAttribute("contenteditable","true");try{o.execCommand("enableObjectResizing",!1,"false"),o.execCommand("enableInlineTableEditing",!1,"false")}catch(e){}e.__squire__=this,this.setHTML("")}function D(){this._restoreSelection=!0}function R(){this._restoreSelection=!1}function U(){this._restoreSelection&&this.setSelection(this._lastSelection)}function P(e,t,n){var o,i;for(o=t.firstChild;o;o=i){if(i=o.nextSibling,a(o)){if(o.nodeType===F||"BR"===o.nodeName||"IMG"===o.nodeName){n.appendChild(o);continue}}else if(s(o)){n.appendChild(e.createDefaultBlock([P(e,o,e._doc.createDocumentFragment())]));continue}P(e,o,n)}return n}var I=2,w=1,F=3,M=9,H=11,W=1,z=4,q=0,K=1,G=2,Z=3,j="highlight",Q="colour",V="font",$="size",Y="​",X=e.defaultView,J=navigator.userAgent,ee=/iP(?:ad|hone|od)/.test(J),te=/Mac OS X/.test(J),ne=/Android/.test(J),oe=/Gecko\//.test(J),ie=/Trident\/[456]\./.test(J),re=!!X.opera,ae=/Edge\//.test(J),se=!ae&&/WebKit\//.test(J),de=/Trident\/[4567]\./.test(J),le=te?"meta-":"ctrl-",ce=ie||re,he=ie||se,ue=ie,fe="undefined"!=typeof MutationObserver,pe="undefined"!=typeof WeakMap,ge=/[^ \t\r\n]/,me=Array.prototype.indexOf;Object.create||(Object.create=function(e){var t=function(){};return t.prototype=e,new t});var ve={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,o=this.nodeType,i=this.filter;;){for(e=t.firstChild;!e&&t&&t!==n;)e=t.nextSibling,e||(t=t.parentNode);if(!e)return null;if(ve[e.nodeType]&o&&i(e))return this.currentNode=e,e;t=e}},n.prototype.previousNode=function(){for(var e,t=this.currentNode,n=this.root,o=this.nodeType,i=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(ve[e.nodeType]&o&&i(e))return this.currentNode=e,e;t=e}},n.prototype.previousPONode=function(){for(var e,t=this.currentNode,n=this.root,o=this.nodeType,i=this.filter;;){for(e=t.lastChild;!e&&t&&t!==n;)e=t.previousSibling,e||(t=t.parentNode);if(!e)return null;if(ve[e.nodeType]&o&&i(e))return this.currentNode=e,e;t=e}};var Ce=/^(?:#text|A(?:BBR|CRONYM)?|B(?:R|D[IO])?|C(?:ITE|ODE)|D(?:ATA|EL|FN)|EM|FONT|HR|I(?:FRAME|MG|NPUT|NS)?|KBD|Q|R(?:P|T|UBY)|S(?:AMP|MALL|PAN|TR(?:IKE|ONG)|U[BP])?|TIME|U|VAR|WBR)$/,_e={BR:1,HR:1,IFRAME:1,IMG:1,INPUT:1},Ne=0,Se=1,ye=2,Te=3,be=pe?new WeakMap:null,Ee=function(e,t){for(var n=e.childNodes;t&&e.nodeType===w;)e=n[t-1],n=e.childNodes,t=n.length;return e},ke=function(e,t){if(e.nodeType===w){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},Be=function(e,t){var n,o,i,r,a=e.startContainer,s=e.startOffset,d=e.endContainer,l=e.endOffset;a.nodeType===F?(n=a.parentNode,o=n.childNodes,s===a.length?(s=me.call(o,a)+1,e.collapsed&&(d=n,l=s)):(s&&(r=a.splitText(s),d===a?(l-=s,d=r):d===n&&(l+=1),a=r),s=me.call(o,a)),a=n):o=a.childNodes,i=o.length,s===i?a.appendChild(t):a.insertBefore(t,o[s]),a===d&&(l+=o.length-i),e.setStart(a,s),e.setEnd(d,l)},xe=function(e,t,n){var o=e.startContainer,i=e.startOffset,r=e.endContainer,a=e.endOffset;t||(t=e.commonAncestorContainer),t.nodeType===F&&(t=t.parentNode);for(var s,d,l,c=b(r,a,t,n),h=b(o,i,t,n),u=t.ownerDocument.createDocumentFragment();h!==c;)s=h.nextSibling,u.appendChild(h),h=s;return o=t,i=c?me.call(t.childNodes,c):t.childNodes.length,l=t.childNodes[i],d=l&&l.previousSibling,d&&d.nodeType===F&&l.nodeType===F&&(o=d,i=d.length,d.appendData(l.data),C(l)),e.setStart(o,i),e.collapse(!0),y(t,n),u},Le=function(e,t){Re(e);var n=e.startContainer,o=e.endContainer,i=(a(n)||s(n))&&(a(o)||s(o)),r=xe(e,null,t);De(e),n=Ue(e,t),i&&(o=Pe(e,t),n&&o&&n!==o&&B(n,o,e)),n&&y(n,t);var d=t.firstChild;return d&&"BR"!==d.nodeName?e.collapse(e.endContainer===t):(y(t,t),e.selectNodeContents(t.firstChild)),r},Ae=function(e,t,n){for(var o=!0,i=t.childNodes,r=i.length;r--;)if(!a(i[r])){o=!1;break}if(e.collapsed||Le(e,n),De(e),o)Be(e,t),e.startContainer!==e.endContainer&&k(e.endContainer,e),k(e.startContainer,e),e.collapse(!1);else{for(var l,u,f,g,m,v=e.startContainer,C=b(v,e.startOffset,p(v.parentNode,n,"BLOCKQUOTE")||n,n),_=C.previousSibling,N=_,S=N.childNodes.length,T=C,E=0,B=C.parentNode;(l=N.lastChild)&&l.nodeType===w;){if("BR"===l.nodeName){S-=1;break}N=l,S=N.childNodes.length}for(;(l=T.firstChild)&&l.nodeType===w&&"BR"!==l.nodeName;)T=l;for(m=N.childNodes[S]||null;(l=t.firstChild)&&a(l);)N.insertBefore(l,m);for(;(l=t.lastChild)&&a(l);)T.insertBefore(l,T.firstChild),E+=1;for(u=t;u=h(u,n);)y(u,n);if(B.insertBefore(t,C),g=_.nextSibling,u=c(g,n),u&&!/\S/.test(u.textContent))do B=u.parentNode,B.removeChild(u),u=B;while(u&&!u.lastChild&&u!==n);if(_.parentNode||(_=g.previousSibling),N.parentNode||(N=_||g.parentNode,S=_?_.childNodes.length:0),d(g)&&x(g,n),f=C.previousSibling,u=s(C)?C:h(C,n),u&&!/\S/.test(u.textContent))do B=u.parentNode,B.removeChild(u),u=B;while(u&&!u.lastChild&&u!==n);C.parentNode||(C=f.nextSibling),E||(T=f,E=f.childNodes.length),C&&d(C)&&x(C,n),e.setStart(N,S),e.setEnd(T,E),De(e)}},Oe=function(e,t,n){var o=t.ownerDocument.createRange();if(o.selectNode(t),n){var i=e.compareBoundaryPoints(Z,o)>-1,r=e.compareBoundaryPoints(K,o)<1;return!i&&!r}var a=e.compareBoundaryPoints(q,o)<1,s=e.compareBoundaryPoints(G,o)>-1;return a&&s},De=function(e){for(var t,n=e.startContainer,o=e.startOffset,r=e.endContainer,a=e.endOffset,s=!0;n.nodeType!==F&&(t=n.childNodes[o],t&&!i(t));)n=t,o=0;if(a)for(;r.nodeType!==F;){if(t=r.childNodes[a-1],!t||i(t)){if(s&&t&&"BR"===t.nodeName){a-=1,s=!1;continue}break}r=t,a=v(r)}else for(;r.nodeType!==F&&(t=r.firstChild,t&&!i(t));)r=t;e.collapsed?(e.setStart(r,a),e.setEnd(n,o)):(e.setStart(n,o),e.setEnd(r,a))},Re=function(e,t){var n,o=e.startContainer,i=e.startOffset,r=e.endContainer,a=e.endOffset,s=!0;for(t||(t=e.commonAncestorContainer);o!==t&&!i;)n=o.parentNode,i=me.call(n.childNodes,o),o=n;for(;;){if(s&&r.nodeType!==F&&r.childNodes[a]&&"BR"===r.childNodes[a].nodeName&&(a+=1,s=!1),r===t||a!==v(r))break;n=r.parentNode,a=me.call(n.childNodes,r)+1,r=n}e.setStart(o,i),e.setEnd(r,a)},Ue=function(e,t){var n,o=e.startContainer;return a(o)?n=c(o,t):o!==t&&s(o)?n=o:(n=Ee(o,e.startOffset),n=h(n,t)),n&&Oe(e,n,!0)?n:null},Pe=function(e,t){var n,o,i=e.endContainer;if(a(i))n=c(i,t);else if(i!==t&&s(i))n=i;else{if(n=ke(i,e.endOffset),!n||!g(t,n))for(n=t;o=n.lastChild;)n=o;n=c(n,t)}return n&&Oe(e,n,!0)?n:null},Ie=new n(null,z|W,function(e){return e.nodeType===F?ge.test(e.data):"IMG"===e.nodeName}),we=function(e,t){var n,o=e.startContainer,i=e.startOffset;if(Ie.root=null,o.nodeType===F){if(i)return!1;n=o}else if(n=ke(o,i),n&&!g(t,n)&&(n=null),!n&&(n=Ee(o,i),n.nodeType===F&&n.length))return!1;return Ie.currentNode=n,Ie.root=Ue(e,t),!Ie.previousNode()},Fe=function(e,t){var n,o=e.endContainer,i=e.endOffset;if(Ie.root=null,o.nodeType===F){if(n=o.data.length,n&&i<n)return!1;Ie.currentNode=o}else Ie.currentNode=Ee(o,i);return Ie.root=Pe(e,t),!Ie.nextNode()},Me=function(e,t){var n,o=Ue(e,t),i=Pe(e,t);o&&i&&(n=o.parentNode,e.setStart(n,me.call(n.childNodes,o)),n=i.parentNode,e.setEnd(n,me.call(n.childNodes,i)+1))},He={8:"backspace",9:"tab",13:"enter",32:"space",33:"pageup",34:"pagedown",37:"left",39:"right",46:"delete",219:"[",221:"]"},We=function(e){var t=e.keyCode,n=He[t],o="",i=this.getSelection();e.defaultPrevented||(n||(n=String.fromCharCode(t).toLowerCase(),/^[A-Za-z0-9]$/.test(n)||(n="")),re&&46===e.which&&(n="."),111<t&&t<124&&(n="f"+(t-111)),"backspace"!==n&&"delete"!==n&&(e.altKey&&(o+="alt-"),e.ctrlKey&&(o+="ctrl-"),e.metaKey&&(o+="meta-")),e.shiftKey&&(o+="shift-"),n=o+n,this._keyHandlers[n]?this._keyHandlers[n](this,e,i):1!==n.length||i.collapsed||(this.saveUndoState(i),Le(i,this._root),this._ensureBottomLine(),this.setSelection(i),this._updatePath(i,!0)))},ze=function(e){return function(t,n){n.preventDefault(),t[e]()}},qe=function(e,t){return t=t||null,function(n,o){o.preventDefault();var i=n.getSelection();n.hasFormat(e,null,i)?n.changeFormat(null,{tag:e},i):n.changeFormat({tag:e},t,i)}},Ke=function(e,t){try{t||(t=e.getSelection());var n,o=t.startContainer;for(o.nodeType===F&&(o=o.parentNode),n=o;a(n)&&(!n.textContent||n.textContent===Y);)o=n,n=o.parentNode;o!==n&&(t.setStart(n,me.call(n.childNodes,o)),t.collapse(!0),n.removeChild(o),s(n)||(n=c(n,e._root)),y(n,e._root),De(t)),o===e._root&&(o=o.firstChild)&&"BR"===o.nodeName&&C(o),e._ensureBottomLine(),e.setSelection(t),e._updatePath(t,!0)}catch(t){e.didError(t)}},Ge={enter:function(e,t,n){var o,i,r,a=e._root;if(t.preventDefault(),e._recordUndoState(n),Lt(n.startContainer,a,e),e._removeZWS(),e._getRangeAndRemoveBookmark(n),n.collapsed||Le(n,a),o=Ue(n,a),!o||/^T[HD]$/.test(o.nodeName))return Be(n,e.createElement("BR")),n.collapse(!1),e.setSelection(n),void e._updatePath(n,!0);if((i=p(o,a,"LI"))&&(o=i),!o.textContent){if(p(o,a,"UL")||p(o,a,"OL"))return e.modifyBlocks(Bt,n);if(p(o,a,"BLOCKQUOTE"))return e.modifyBlocks(St,n)}for(r=Ct(e,o,n.startContainer,n.startOffset),pt(o),tt(o),y(o,a);r.nodeType===w;){var s,d=r.firstChild;if("A"===r.nodeName&&(!r.textContent||r.textContent===Y)){d=e._doc.createTextNode(""),_(r,d),r=d;break}for(;d&&d.nodeType===F&&!d.data&&(s=d.nextSibling,s&&"BR"!==s.nodeName);)C(d),d=s;if(!d||"BR"===d.nodeName||d.nodeType===F&&!re)break;r=d}n=e._createRange(r,0),e.setSelection(n),e._updatePath(n,!0)},backspace:function(e,t,n){var o=e._root;if(e._removeZWS(),e.saveUndoState(n),n.collapsed)if(we(n,o)){t.preventDefault();var i,r=Ue(n,o);if(!r)return;if(T(r.parentNode,o),i=c(r,o)){if(!i.isContentEditable)return void C(i);for(B(i,r,n),r=i.parentNode;r!==o&&!r.nextSibling;)r=r.parentNode;r!==o&&(r=r.nextSibling)&&x(r,o),e.setSelection(n)}else if(r){if(p(r,o,"UL")||p(r,o,"OL"))return e.modifyBlocks(Bt,n);if(p(r,o,"BLOCKQUOTE"))return e.modifyBlocks(Nt,n);e.setSelection(n),e._updatePath(n,!0)}}else e.setSelection(n),setTimeout(function(){Ke(e)},0);else t.preventDefault(),Le(n,o),Ke(e,n)},delete:function(e,t,n){var o,i,r,a,s,d,l=e._root;if(e._removeZWS(),e.saveUndoState(n),n.collapsed)if(Fe(n,l)){if(t.preventDefault(),o=Ue(n,l),!o)return;if(T(o.parentNode,l),i=h(o,l)){if(!i.isContentEditable)return void C(i);for(B(o,i,n),i=o.parentNode;i!==l&&!i.nextSibling;)i=i.parentNode;i!==l&&(i=i.nextSibling)&&x(i,l),e.setSelection(n),e._updatePath(n,!0)}}else{if(r=n.cloneRange(),Re(n,e._root),a=n.endContainer,s=n.endOffset,a.nodeType===w&&(d=a.childNodes[s],d&&"IMG"===d.nodeName))return t.preventDefault(),C(d),De(n),void Ke(e,n);e.setSelection(r),setTimeout(function(){Ke(e)},0)}else t.preventDefault(),Le(n,l),Ke(e,n)},tab:function(e,t,n){var o,i,r=e._root;if(e._removeZWS(),n.collapsed&&we(n,r))for(o=Ue(n,r);i=o.parentNode;){if("UL"===i.nodeName||"OL"===i.nodeName){t.preventDefault(),e.modifyBlocks(kt,n);break}o=i}},"shift-tab":function(e,t,n){var o,i=e._root;e._removeZWS(),n.collapsed&&we(n,i)&&(o=n.startContainer,(p(o,i,"UL")||p(o,i,"OL"))&&(t.preventDefault(),e.modifyBlocks(Bt,n)))},space:function(e,t,n){var o,i;e._recordUndoState(n),Lt(n.startContainer,e._root,e),e._getRangeAndRemoveBookmark(n),o=n.endContainer,i=o.parentNode,n.collapsed&&"A"===i.nodeName&&!o.nextSibling&&n.endOffset===v(o)?n.setStartAfter(i):n.collapsed||(Le(n,e._root),e._ensureBottomLine(),e.setSelection(n),e._updatePath(n,!0)),e.setSelection(n)},left:function(e){e._removeZWS()},right:function(e){e._removeZWS()}};te&&oe&&(Ge["meta-left"]=function(e,t){t.preventDefault();var n=ft(e);n&&n.modify&&n.modify("move","backward","lineboundary")},Ge["meta-right"]=function(e,t){t.preventDefault();var n=ft(e);n&&n.modify&&n.modify("move","forward","lineboundary")}),te||(Ge.pageup=function(e){e.moveCursorToStart()},Ge.pagedown=function(e){e.moveCursorToEnd()}),Ge[le+"b"]=qe("B"),Ge[le+"i"]=qe("I"),Ge[le+"u"]=qe("U"),Ge[le+"shift-7"]=qe("S"),Ge[le+"shift-5"]=qe("SUB",{tag:"SUP"}),Ge[le+"shift-6"]=qe("SUP",{tag:"SUB"}),Ge[le+"shift-8"]=ze("makeUnorderedList"),Ge[le+"shift-9"]=ze("makeOrderedList"),Ge[le+"["]=ze("decreaseQuoteLevel"),Ge[le+"]"]=ze("increaseQuoteLevel"),Ge[le+"y"]=ze("redo"),Ge[le+"z"]=ze("undo"),Ge[le+"shift-z"]=ze("redo");var Ze={1:10,2:13,3:16,4:18,5:24,6:32,7:48},je={backgroundColor:{regexp:ge,replace:function(e,t){return S(e,"SPAN",{class:j,style:"background-color:"+t})}},color:{regexp:ge,replace:function(e,t){return S(e,"SPAN",{class:Q,style:"color:"+t})}},fontWeight:{regexp:/^bold|^700/i,replace:function(e){return S(e,"B")}},fontStyle:{regexp:/^italic/i,replace:function(e){return S(e,"I")}},fontFamily:{regexp:ge,replace:function(e,t){return S(e,"SPAN",{class:V,style:"font-family:"+t})}},fontSize:{regexp:ge,replace:function(e,t){return S(e,"SPAN",{class:$,style:"font-size:"+t})}},textDecoration:{regexp:/^underline/i,replace:function(e){return S(e,"U")}}},Qe=function(e){return function(t,n){var o=S(t.ownerDocument,e);return n.replaceChild(o,t),o.appendChild(N(t)),o}},Ve=function(e,t){var n,o,i,r,a,s,d=e.style,l=e.ownerDocument;for(n in je)o=je[n],i=d[n],i&&o.regexp.test(i)&&(s=o.replace(l,i),a||(a=s),r&&r.appendChild(s),r=s,e.style[n]="");return a&&(r.appendChild(N(e)),"SPAN"===e.nodeName?t.replaceChild(a,e):e.appendChild(a)),r||e},$e={P:Ve,SPAN:Ve,STRONG:Qe("B"),EM:Qe("I"),INS:Qe("U"),STRIKE:Qe("S"),FONT:function(e,t){var n,o,i,r,a,s=e.face,d=e.size,l=e.color,c=e.ownerDocument;return s&&(n=S(c,"SPAN",{class:V,style:"font-family:"+s}),a=n,r=n),d&&(o=S(c,"SPAN",{class:$,style:"font-size:"+Ze[d]+"px"}),a||(a=o),r&&r.appendChild(o),r=o),l&&/^#?([\dA-F]{3}){1,2}$/i.test(l)&&("#"!==l.charAt(0)&&(l="#"+l),i=S(c,"SPAN",{class:Q,style:"color:"+l}),a||(a=i),r&&r.appendChild(i),r=i),a||(a=r=S(c,"SPAN")),t.replaceChild(a,e),r.appendChild(N(e)),r},TT:function(e,t){var n=S(e.ownerDocument,"SPAN",{class:V,style:'font-family:menlo,consolas,"courier new",monospace'});return t.replaceChild(n,e),n.appendChild(N(e)),n}},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)|COL(?:GROUP)?|UL)$/,Xe=/^(?:HEAD|META|STYLE)/,Je=new n(null,z|W,function(){return!0}),et=function e(t,n){var o,i,r,s,d,l,c,h,u,f,p,g,m=t.childNodes;for(o=t;a(o);)o=o.parentNode;for(Je.root=o,i=0,r=m.length;i<r;i+=1)if(s=m[i],d=s.nodeName,l=s.nodeType,c=$e[d],l===w){if(h=s.childNodes.length,c)s=c(s,t);else{if(Xe.test(d)){t.removeChild(s),i-=1,r-=1;continue}if(!Ye.test(d)&&!a(s)){i-=1,r+=h-1,t.replaceChild(N(s),s);continue}}h&&e(s,n||"PRE"===d)}else{if(l===F){if(p=s.data,u=!ge.test(p.charAt(0)),f=!ge.test(p.charAt(p.length-1)),n||!u&&!f)continue;if(u){for(Je.currentNode=s;(g=Je.previousPONode())&&(d=g.nodeName,!("IMG"===d||"#text"===d&&ge.test(g.data)));)if(!a(g)){g=null;break}p=p.replace(/^[ \t\r\n]+/g,g?" ":"")}if(f){for(Je.currentNode=s;(g=Je.nextNode())&&!("IMG"===d||"#text"===d&&ge.test(g.data));)if(!a(g)){g=null;break}p=p.replace(/[ \t\r\n]+$/g,g?" ":"")}if(p){s.data=p;continue}}t.removeChild(s),i-=1,r-=1}return t},tt=function e(t){for(var n,o=t.childNodes,r=o.length;r--;)n=o[r],n.nodeType!==w||i(n)?n.nodeType!==F||n.data||t.removeChild(n):(e(n),a(n)&&!n.firstChild&&t.removeChild(n))},nt=function(e){return e.nodeType===w?"BR"===e.nodeName:ge.test(e.data)},ot=function(e){for(var t,o=e.parentNode;a(o);)o=o.parentNode;return t=new n(o,W|z,nt),t.currentNode=e,!!t.nextNode()},it=function(e,t){var n,o,i,r=e.querySelectorAll("BR"),s=[],d=r.length;for(n=0;n<d;n+=1)s[n]=ot(r[n]);for(;d--;)o=r[d],i=o.parentNode,i&&(s[d]?a(i)||T(i,t):C(o))},rt=function(e,t){var n=t.ownerDocument.body;t.setAttribute("style","position:fixed;overflow:hidden;bottom:100%;right:100%;"),n.appendChild(t),e.setData("text/html",t.innerHTML),e.setData("text/plain",t.innerText||t.textContent),n.removeChild(t)},at=function(e){var t=e.clipboardData,n=this.getSelection(),o=this.createElement("div"),i=this._root,r=this;this.saveUndoState(n),ae||ee||!t?setTimeout(function(){try{r._ensureBottomLine()}catch(e){r.didError(e)}},0):(Re(n,i),o.appendChild(Le(n,i)),rt(t,o),e.preventDefault()),this.setSelection(n)},st=function(e){var t,n,o,i,r,a,s=e.clipboardData,d=this.getSelection(),l=this.createElement("div"),c=this._root;if(!ae&&!ee&&s){for(d=d.cloneRange(),t=Ue(d,c),n=Pe(d,c),o=t===n&&t||c,De(d),Re(d,o),i=d.cloneContents(),r=d.commonAncestorContainer,r.nodeType===F&&(r=r.parentNode);r&&r!==o;)a=r.cloneNode(!1),a.appendChild(i),i=a,r=r.parentNode;l.appendChild(i),rt(s,l),e.preventDefault()}},dt=function(e){var t,n,o,i,r,a=e.clipboardData,s=a&&a.items,d=this.isShiftDown,l=!1,c=!1,h=null,u=this;if(!ae&&s){for(e.preventDefault(),t=s.length;t--;){if(n=s[t],o=n.type,!d&&"text/html"===o)return void n.getAsString(function(e){u.insertHTML(e,!0)});"text/plain"===o&&(h=n),!d&&/^image\/.*/.test(o)&&(c=!0)}return void(c?(this.fireEvent("dragover",{dataTransfer:a,preventDefault:function(){l=!0}}),l&&this.fireEvent("drop",{dataTransfer:a})):h&&h.getAsString(function(e){u.insertPlainText(e,!0)}))}if(i=a&&a.types,!ae&&i&&(me.call(i,"text/html")>-1||!oe&&me.call(i,"text/plain")>-1&&me.call(i,"text/rtf")<0))return e.preventDefault(),void(!d&&(r=a.getData("text/html"))?this.insertHTML(r,!0):((r=a.getData("text/plain"))||(r=a.getData("text/uri-list")))&&this.insertPlainText(r,!0));this._awaitingPaste=!0;var f=this._doc.body,p=this.getSelection(),g=p.startContainer,m=p.startOffset,v=p.endContainer,_=p.endOffset,N=this.createElement("DIV",{contenteditable:"true",style:"position:fixed; overflow:hidden; top:0; right:100%; width:1px; height:1px;"});f.appendChild(N),p.selectNodeContents(N),this.setSelection(p),setTimeout(function(){try{u._awaitingPaste=!1;for(var e,t,n="",o=N;N=o;)o=N.nextSibling,C(N),e=N.firstChild,e&&e===N.lastChild&&"DIV"===e.nodeName&&(N=e),n+=N.innerHTML;t=u._createRange(g,m,v,_),u.setSelection(t),n&&u.insertHTML(n,!0)}catch(e){u.didError(e)}},0)},lt=function(e){for(var t=e.dataTransfer.types,n=t.length,o=!1,i=!1;n--;)switch(t[n]){case"text/plain":o=!0;break;case"text/html":i=!0;break;default:return}(i||o)&&this.saveUndoState()},ct=O.prototype,ht=function(t){var n=DOMPurify.sanitize(t,{WHOLE_DOCUMENT:!1,RETURN_DOM:!0,RETURN_DOM_FRAGMENT:!0});return e.importNode(n,!0)};ct.setConfig=function(e){return e=A({blockTag:"DIV",blockAttributes:null,tagAttributes:{blockquote:null,ul:null,ol:null,li:null,a:null},leafNodeNames:_e,undo:{documentSizeThreshold:-1,undoLimit:-1},isInsertedHTMLSanitized:!0,isSetHTMLSanitized:!0,sanitizeToDOMFragment:"undefined"!=typeof DOMPurify&&DOMPurify.isSupported?ht:null},e,!0),e.blockTag=e.blockTag.toUpperCase(),this._config=e,this},ct.createElement=function(e,t,n){return S(this._doc,e,t,n)},ct.createDefaultBlock=function(e){var t=this._config;return y(this.createElement(t.blockTag,t.blockAttributes,e),this._root)},ct.didError=function(e){console.log(e)},ct.getDocument=function(){return this._doc},ct.getRoot=function(){return this._root},ct.modifyDocument=function(e){this._ignoreAllChanges=!0,this._mutation&&this._mutation.disconnect(),e(),this._ignoreAllChanges=!1,this._mutation&&(this._mutation.observe(this._root,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),this._ignoreChange=!1)};var ut={pathChange:1,select:1,input:1,undoStateChange:1};ct.fireEvent=function(e,t){var n,o,i,r=this._events[e];if(/^(?:focus|blur)/.test(e))if(n=g(this._root,this._doc.activeElement),"focus"===e){if(!n||this._isFocused)return this;this._isFocused=!0}else{if(n||!this._isFocused)return this;this._isFocused=!1}if(r)for(t||(t={}),t.type!==e&&(t.type=e),r=r.slice(),o=r.length;o--;){i=r[o];try{i.handleEvent?i.handleEvent(t):i.call(this,t)}catch(t){t.details="Squire: fireEvent error. Event type: "+e,this.didError(t)}}return this},ct.destroy=function(){var e,t=this._events;for(e in t)this.removeEventListener(e);this._mutation&&this._mutation.disconnect(),delete this._root.__squire__,this._undoIndex=-1,this._undoStack=[],this._undoStackLength=0},ct.handleEvent=function(e){this.fireEvent(e.type,e)},ct.addEventListener=function(e,t){var n=this._events[e],o=this._root;return t?(n||(n=this._events[e]=[],ut[e]||("selectionchange"===e&&(o=this._doc),o.addEventListener(e,this,!0))),n.push(t),this):(this.didError({name:"Squire: addEventListener with null or undefined fn",message:"Event type: "+e}),this)},ct.removeEventListener=function(e,t){var n,o=this._events[e],i=this._root;if(o){if(t)for(n=o.length;n--;)o[n]===t&&o.splice(n,1);else o.length=0;o.length||(delete this._events[e],ut[e]||("selectionchange"===e&&(i=this._doc),i.removeEventListener(e,this,!0)))}return this},ct._createRange=function(e,t,n,o){if(e instanceof this._win.Range)return e.cloneRange();var i=this._doc.createRange();return i.setStart(e,t),n?i.setEnd(n,o):i.setEnd(e,t),i},ct.getCursorPosition=function(e){if(!e&&!(e=this.getSelection())||!e.getBoundingClientRect)return null;var t,n,o=e.getBoundingClientRect();return o&&!o.top&&(this._ignoreChange=!0,t=this._doc.createElement("SPAN"),t.textContent=Y,Be(e,t),o=t.getBoundingClientRect(),n=t.parentNode,n.removeChild(t),k(n,e)),o},ct._moveCursorTo=function(e){var t=this._root,n=this._createRange(t,e?0:t.childNodes.length);return De(n),this.setSelection(n),this},ct.moveCursorToStart=function(){return this._moveCursorTo(!0)},ct.moveCursorToEnd=function(){return this._moveCursorTo(!1)};var ft=function(e){return e._win.getSelection()||null};ct.setSelection=function(e){if(e)if(this._lastSelection=e,this._isFocused)if(ne&&!this._restoreSelection)D.call(this),this.blur(),this.focus();else{ee&&this._win.focus();var t=ft(this);t&&(t.removeAllRanges(),t.addRange(e))}else D.call(this);return this},ct.getSelection=function(){var e,t,n,o=ft(this),r=this._root;return o&&o.rangeCount&&(e=o.getRangeAt(0).cloneRange(),t=e.startContainer,n=e.endContainer,t&&i(t)&&e.setStartBefore(t),n&&i(n)&&e.setEndBefore(n)),e&&g(r,e.commonAncestorContainer)?this._lastSelection=e:e=this._lastSelection,e||(e=this._createRange(r.firstChild,0)),e},ct.getSelectedText=function(){var e,t=this.getSelection(),o=new n(t.commonAncestorContainer,z|W,function(e){return Oe(t,e,!0)}),i=t.startContainer,r=t.endContainer,s=o.currentNode=i,d="",l=!1;for(o.filter(s)||(s=o.nextNode());s;)s.nodeType===F?(e=s.data,e&&/\S/.test(e)&&(s===r&&(e=e.slice(0,t.endOffset)),s===i&&(e=e.slice(t.startOffset)),d+=e,l=!0)):("BR"===s.nodeName||l&&!a(s))&&(d+="\n",l=!1),s=o.nextNode();return d},ct.getPath=function(){return this._path};var pt=function(e,t){for(var o,i,r,s=new n(e,z,function(){return!0},!1);i=s.nextNode();)for(;(r=i.data.indexOf(Y))>-1&&(!t||i.parentNode!==t);){if(1===i.length){do o=i.parentNode,o.removeChild(i),i=o,s.currentNode=o;while(a(i)&&!v(i));break}i.deleteData(r,1)}};ct._didAddZWS=function(){this._hasZWS=!0},ct._removeZWS=function(){this._hasZWS&&(pt(this._root),this._hasZWS=!1)},ct._updatePath=function(e,t){var n,o=e.startContainer,i=e.endContainer;(t||o!==this._lastAnchorNode||i!==this._lastFocusNode)&&(this._lastAnchorNode=o,this._lastFocusNode=i,n=o&&i?o===i?m(i,this._root):"(selection)":"",this._path!==n&&(this._path=n,this.fireEvent("pathChange",{path:n}))),e.collapsed||this.fireEvent("select")},ct._updatePathOnEvent=function(){var e=this;e._willUpdatePath||(e._willUpdatePath=!0,setTimeout(function(){e._willUpdatePath=!1,e._updatePath(e.getSelection())},0))},ct.focus=function(){return this._root.focus(),de&&this.fireEvent("focus"),this},ct.blur=function(){return this._root.blur(),de&&this.fireEvent("blur"),this};var gt="squire-selection-start",mt="squire-selection-end";ct._saveRangeToBookmark=function(e){var t,n=this.createElement("INPUT",{id:gt,type:"hidden"}),o=this.createElement("INPUT",{id:mt,type:"hidden"});Be(e,n),e.collapse(!1),Be(e,o),n.compareDocumentPosition(o)&I&&(n.id=mt,o.id=gt,t=n,n=o,o=t),e.setStartAfter(n),e.setEndBefore(o)},ct._getRangeAndRemoveBookmark=function(e){var t=this._root,n=t.querySelector("#"+gt),o=t.querySelector("#"+mt);if(n&&o){var i=n.parentNode,r=o.parentNode,a=me.call(i.childNodes,n),s=me.call(r.childNodes,o);i===r&&(s-=1),C(n),C(o),e||(e=this._doc.createRange()),e.setStart(i,a),e.setEnd(r,s),k(i,e),i!==r&&k(r,e),e.collapsed&&(i=e.startContainer,i.nodeType===F&&(r=i.childNodes[e.startOffset],r&&r.nodeType===F||(r=i.childNodes[e.startOffset-1]),r&&r.nodeType===F&&(e.setStart(r,0),e.collapse(!0))))}return e||null},ct._keyUpDetectChange=function(e){var t=e.keyCode;e.ctrlKey||e.metaKey||e.altKey||!(t<16||t>20)||!(t<33||t>45)||this._docWasChanged()},ct._docWasChanged=function(){if(pe&&(be=new WeakMap),!this._ignoreAllChanges){if(fe&&this._ignoreChange)return void(this._ignoreChange=!1);this._isInUndoState&&(this._isInUndoState=!1,this.fireEvent("undoStateChange",{canUndo:!0,canRedo:!1})),this.fireEvent("input")}},ct._recordUndoState=function(e){if(!this._isInUndoState){var t,n=this._undoIndex+=1,o=this._undoStack,i=this._config.undo,r=i.documentSizeThreshold,a=i.undoLimit;n<this._undoStackLength&&(o.length=this._undoStackLength=n),e&&this._saveRangeToBookmark(e),t=this._getHTML(),r>-1&&2*t.length>r&&a>-1&&n>a&&(o.splice(0,n-a),n=this._undoIndex=a,this._undoStackLength=a),o[n]=t,this._undoStackLength+=1,
+this._isInUndoState=!0}},ct.saveUndoState=function(e){return e===t&&(e=this.getSelection()),this._isInUndoState||(this._recordUndoState(e),this._getRangeAndRemoveBookmark(e)),this},ct.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},ct.redo=function(){var e=this._undoIndex,t=this._undoStackLength;if(e+1<t&&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:e+2<t}),this.fireEvent("input")}return this},ct.hasFormat=function(e,t,o){if(e=e.toUpperCase(),t||(t={}),!o&&!(o=this.getSelection()))return!1;!o.collapsed&&o.startContainer.nodeType===F&&o.startOffset===o.startContainer.length&&o.startContainer.nextSibling&&o.setStartBefore(o.startContainer.nextSibling),!o.collapsed&&o.endContainer.nodeType===F&&0===o.endOffset&&o.endContainer.previousSibling&&o.setEndAfter(o.endContainer.previousSibling);var i,r,a=this._root,s=o.commonAncestorContainer;if(p(s,a,e,t))return!0;if(s.nodeType===F)return!1;i=new n(s,z,function(e){return Oe(o,e,!0)},!1);for(var d=!1;r=i.nextNode();){if(!p(r,a,e,t))return!1;d=!0}return d},ct.getFontInfo=function(e){var n,o,i,r={color:t,backgroundColor:t,family:t,size:t},a=0;if(!e&&!(e=this.getSelection()))return r;if(n=e.commonAncestorContainer,e.collapsed||n.nodeType===F)for(n.nodeType===F&&(n=n.parentNode);a<4&&n;)(o=n.style)&&(!r.color&&(i=o.color)&&(r.color=i,a+=1),!r.backgroundColor&&(i=o.backgroundColor)&&(r.backgroundColor=i,a+=1),!r.family&&(i=o.fontFamily)&&(r.family=i,a+=1),!r.size&&(i=o.fontSize)&&(r.size=i,a+=1)),n=n.parentNode;return r},ct._addFormat=function(e,t,o){var i,r,s,d,l,c,h,u,f,g=this._root;if(o.collapsed){for(i=y(this.createElement(e,t),g),Be(o,i),o.setStart(i.firstChild,i.firstChild.length),o.collapse(!0),f=i;a(f);)f=f.parentNode;pt(f,i)}else{if(r=new n(o.commonAncestorContainer,z|W,function(e){return(e.nodeType===F||"BR"===e.nodeName||"IMG"===e.nodeName)&&Oe(o,e,!0)},!1),s=o.startContainer,l=o.startOffset,d=o.endContainer,c=o.endOffset,r.currentNode=s,r.filter(s)||(s=r.nextNode(),l=0),!s)return o;do h=r.currentNode,u=!p(h,g,e,t),u&&(h===d&&h.length>c&&h.splitText(c),h===s&&l&&(h=h.splitText(l),d===s&&(d=h,c-=l),s=h,l=0),i=this.createElement(e,t),_(h,i),i.appendChild(h));while(r.nextNode());d.nodeType!==F&&(h.nodeType===F?(d=h,c=h.length):(d=h.parentNode,c=1)),o=this._createRange(s,l,d,c)}return o},ct._removeFormat=function(e,t,n,o){this._saveRangeToBookmark(n);var i,r=this._doc;n.collapsed&&(he?(i=r.createTextNode(Y),this._didAddZWS()):i=r.createTextNode(""),Be(n,i));for(var s=n.commonAncestorContainer;a(s);)s=s.parentNode;var d=n.startContainer,l=n.startOffset,c=n.endContainer,h=n.endOffset,u=[],p=function(e,t){if(!Oe(n,e,!1)){var o,i,r=e.nodeType===F;if(!Oe(n,e,!0))return void("INPUT"===e.nodeName||r&&!e.data||u.push([t,e]));if(r)e===c&&h!==e.length&&u.push([t,e.splitText(h)]),e===d&&l&&(e.splitText(l),u.push([t,e]));else for(o=e.firstChild;o;o=i)i=o.nextSibling,p(o,t)}},g=Array.prototype.filter.call(s.getElementsByTagName(e),function(o){return Oe(n,o,!0)&&f(o,e,t)});return o||g.forEach(function(e){p(e,e)}),u.forEach(function(e){var t=e[0].cloneNode(!1),n=e[1];_(n,t),t.appendChild(n)}),g.forEach(function(e){_(e,N(e))}),this._getRangeAndRemoveBookmark(n),i&&n.collapse(!1),k(s,n),n},ct.changeFormat=function(e,t,n,o){return n||(n=this.getSelection())?(this.saveUndoState(n),t&&(n=this._removeFormat(t.tag.toUpperCase(),t.attributes||{},n,o)),e&&(n=this._addFormat(e.tag.toUpperCase(),e.attributes||{},n)),this.setSelection(n),this._updatePath(n,!0),fe||this._docWasChanged(),this):this};var vt={DT:"DD",DD:"DT",LI:"LI"},Ct=function(e,t,n,o){var i=vt[t.nodeName],r=null,a=b(n,o,t.parentNode,e._root),s=e._config;return i||(i=s.blockTag,r=s.blockAttributes),f(a,i,r)||(t=S(a.ownerDocument,i,r),a.dir&&(t.dir=a.dir),_(a,t),t.appendChild(N(a)),a=t),a};ct.forEachBlock=function(e,t,n){if(!n&&!(n=this.getSelection()))return this;t&&this.saveUndoState(n);var o=this._root,i=Ue(n,o),r=Pe(n,o);if(i&&r)do if(e(i)||i===r)break;while(i=h(i,o));return t&&(this.setSelection(n),this._updatePath(n,!0),fe||this._docWasChanged()),this},ct.modifyBlocks=function(e,t){if(!t&&!(t=this.getSelection()))return this;this._isInUndoState?this._saveRangeToBookmark(t):this._recordUndoState(t);var n,o=this._root;return Me(t,o),Re(t,o),n=xe(t,o,o),Be(t,e.call(this,n)),t.endOffset<t.endContainer.childNodes.length&&x(t.endContainer.childNodes[t.endOffset],o),x(t.startContainer.childNodes[t.startOffset],o),this._getRangeAndRemoveBookmark(t),this.setSelection(t),this._updatePath(t,!0),fe||this._docWasChanged(),this};var _t=function(e){return this.createElement("BLOCKQUOTE",this._config.tagAttributes.blockquote,[e])},Nt=function(e){var t=this._root,n=e.querySelectorAll("blockquote");return Array.prototype.filter.call(n,function(e){return!p(e.parentNode,t,"BLOCKQUOTE")}).forEach(function(e){_(e,N(e))}),e},St=function(){return this.createDefaultBlock([this.createElement("INPUT",{id:gt,type:"hidden"}),this.createElement("INPUT",{id:mt,type:"hidden"})])},yt=function(e,t,n){for(var o,i,r,a,s=l(t,e._root),d=e._config.tagAttributes,c=d[n.toLowerCase()],h=d.li;o=s.nextNode();)"LI"===o.parentNode.nodeName&&(o=o.parentNode,s.currentNode=o.lastChild),"LI"!==o.nodeName?(a=e.createElement("LI",h),o.dir&&(a.dir=o.dir),(r=o.previousSibling)&&r.nodeName===n?(r.appendChild(a),C(o)):_(o,e.createElement(n,c,[a])),a.appendChild(N(o)),s.currentNode=a):(o=o.parentNode,i=o.nodeName,i!==n&&/^[OU]L$/.test(i)&&_(o,e.createElement(n,c,[N(o)])))},Tt=function(e){return yt(this,e,"UL"),e},bt=function(e){return yt(this,e,"OL"),e},Et=function(e){var t,n,o,i,r,a=e.querySelectorAll("UL, OL"),d=e.querySelectorAll("LI"),l=this._root;for(t=0,n=a.length;t<n;t+=1)o=a[t],i=N(o),T(i,l),_(o,i);for(t=0,n=d.length;t<n;t+=1)r=d[t],s(r)?_(r,this.createDefaultBlock([N(r)])):(T(r,l),_(r,N(r)));return e},kt=function(e){var t,n,o,i,r,a,s=e.querySelectorAll("LI"),l=this._config.tagAttributes;for(t=0,n=s.length;t<n;t+=1)o=s[t],d(o.firstChild)||(i=o.parentNode.nodeName,r=o.previousSibling,r&&(r=r.lastChild)&&r.nodeName===i||(a=l[i.toLowerCase()],r=this.createElement(i,a),_(o,r)),r.appendChild(o));return e},Bt=function(e){var t=this._root,n=e.querySelectorAll("LI");return Array.prototype.filter.call(n,function(e){return!d(e.firstChild)}).forEach(function(n){var o,i=n.parentNode,r=i.parentNode,a=n.firstChild,s=a;if(n.previousSibling&&(i=b(i,n,r,t)),/^[OU]L$/.test(r.nodeName))r.insertBefore(n,i),i.firstChild||r.removeChild(i);else for(;s&&(o=s.nextSibling,!d(s));)r.insertBefore(s,i),s=o;for("LI"===r.nodeName&&a.previousSibling&&b(r,a,r.parentNode,t);n!==e&&!n.childNodes.length;)i=n.parentNode,i.removeChild(n),n=i},this),T(e,t),e};ct._ensureBottomLine=function(){var e=this._root,t=e.lastElementChild;t&&t.nodeName===this._config.blockTag&&s(t)||e.appendChild(this.createDefaultBlock())},ct.setKeyHandler=function(e,t){return this._keyHandlers[e]=t,this},ct._getHTML=function(){return this._root.innerHTML},ct._setHTML=function(e){var t=this._root,n=t;n.innerHTML=e;do y(n,t);while(n=h(n,t));this._ignoreChange=!0},ct.getHTML=function(e){var t,n,o,i,r,a,s=[];if(e&&(a=this.getSelection())&&this._saveRangeToBookmark(a),ce)for(t=this._root,n=t;n=h(n,t);)n.textContent||n.querySelector("BR")||(o=this.createElement("BR"),n.appendChild(o),s.push(o));if(i=this._getHTML().replace(/\u200B/g,""),ce)for(r=s.length;r--;)C(s[r]);return a&&this._getRangeAndRemoveBookmark(a),i},ct.setHTML=function(e){var t,n,o,i=this._config,r=i.isSetHTMLSanitized?i.sanitizeToDOMFragment:null,a=this._root;"function"==typeof r?n=r(e,!1):(t=this.createElement("DIV"),t.innerHTML=e,n=this._doc.createDocumentFragment(),n.appendChild(N(t))),et(n),it(n,a),T(n,a);for(var s=n;s=h(s,a);)y(s,a);for(this._ignoreChange=!0;o=a.lastChild;)a.removeChild(o);a.appendChild(n),y(a,a),this._undoIndex=-1,this._undoStack.length=0,this._undoStackLength=0,this._isInUndoState=!1;var d=this._getRangeAndRemoveBookmark()||this._createRange(a.firstChild,0);return this.saveUndoState(d),this._lastSelection=d,D.call(this),this._updatePath(d,!0),this},ct.insertElement=function(e,t){if(t||(t=this.getSelection()),t.collapse(!0),a(e))Be(t,e),t.setStartAfter(e);else{for(var n,o,i=this._root,r=Ue(t,i)||i;r!==i&&!r.nextSibling;)r=r.parentNode;r!==i&&(n=r.parentNode,o=b(n,r.nextSibling,i,i)),o?i.insertBefore(e,o):(i.appendChild(e),o=this.createDefaultBlock(),i.appendChild(o)),t.setStart(o,0),t.setEnd(o,0),De(t)}return this.focus(),this.setSelection(t),this._updatePath(t),fe||this._docWasChanged(),this},ct.insertImage=function(e,t){var n=this.createElement("IMG",A({src:e},t,!0));return this.insertElement(n),n};var xt=/\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,Lt=function(e,t,o){for(var i,r,a,s,d,l,c,h=e.ownerDocument,u=new n(e,z,function(e){return!p(e,t,"A")},!1),f=o._config.tagAttributes.a;i=u.nextNode();)for(r=i.data,a=i.parentNode;s=xt.exec(r);)d=s.index,l=d+s[0].length,d&&(c=h.createTextNode(r.slice(0,d)),a.insertBefore(c,i)),c=o.createElement("A",A({href:s[1]?/^(?:ht|f)tps?:/.test(s[1])?s[1]:"http://"+s[1]:"mailto:"+s[2]},f,!1)),c.textContent=r.slice(d,l),a.insertBefore(c,i),i.data=r=r.slice(l)};ct.insertHTML=function(e,t){var n,o,i,r,a,s,d,l=this._config,c=l.isInsertedHTMLSanitized?l.sanitizeToDOMFragment:null,u=this.getSelection(),f=this._doc;"function"==typeof c?r=c(e,t):(t&&(n=e.indexOf("<!--StartFragment-->"),o=e.lastIndexOf("<!--EndFragment-->"),n>-1&&o>-1&&(e=e.slice(n+20,o))),i=this.createElement("DIV"),i.innerHTML=e,r=f.createDocumentFragment(),r.appendChild(N(i))),this.saveUndoState(u);try{for(a=this._root,s=r,d={fragment:r,preventDefault:function(){this.defaultPrevented=!0},defaultPrevented:!1},Lt(r,r,this),et(r),it(r,a),tt(r),r.normalize();s=h(s,r);)y(s,a);t&&this.fireEvent("willPaste",d),d.defaultPrevented||(Ae(u,d.fragment,a),fe||this._docWasChanged(),u.collapse(!1),this._ensureBottomLine()),this.setSelection(u),this._updatePath(u,!0),t&&this.focus()}catch(e){this.didError(e)}return this};var At=function(e){return e.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;").split('"').join("&quot;")};ct.insertPlainText=function(e,t){var n,o,i,r,a=e.split("\n"),s=this._config,d=s.blockTag,l=s.blockAttributes,c="</"+d+">",h="<"+d;for(n in l)h+=" "+n+'="'+At(l[n])+'"';for(h+=">",o=0,i=a.length;o<i;o+=1)r=a[o],r=At(r).replace(/ (?= )/g,"&nbsp;"),o&&o+1<i&&(r=h+(r||"<BR>")+c),a[o]=r;return this.insertHTML(a.join(""),t)};var Ot=function(e,t,n){return function(){return this[e](t,n),this.focus()}};ct.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},ct.bold=Ot("changeFormat",{tag:"B"}),ct.italic=Ot("changeFormat",{tag:"I"}),ct.underline=Ot("changeFormat",{tag:"U"}),ct.strikethrough=Ot("changeFormat",{tag:"S"}),ct.subscript=Ot("changeFormat",{tag:"SUB"},{tag:"SUP"}),ct.superscript=Ot("changeFormat",{tag:"SUP"},{tag:"SUB"}),ct.removeBold=Ot("changeFormat",null,{tag:"B"}),ct.removeItalic=Ot("changeFormat",null,{tag:"I"}),ct.removeUnderline=Ot("changeFormat",null,{tag:"U"}),ct.removeStrikethrough=Ot("changeFormat",null,{tag:"S"}),ct.removeSubscript=Ot("changeFormat",null,{tag:"SUB"}),ct.removeSuperscript=Ot("changeFormat",null,{tag:"SUP"}),ct.makeLink=function(e,t){var n=this.getSelection();if(n.collapsed){var o=e.indexOf(":")+1;if(o)for(;"/"===e[o];)o+=1;Be(n,this._doc.createTextNode(e.slice(o)))}return t=A(A({href:e},t,!0),this._config.tagAttributes.a,!1),this.changeFormat({tag:"A",attributes:t},{tag:"A"},n),this.focus()},ct.removeLink=function(){return this.changeFormat(null,{tag:"A"},this.getSelection(),!0),this.focus()},ct.setFontFace=function(e){return this.changeFormat(e?{tag:"SPAN",attributes:{class:V,style:"font-family: "+e+", sans-serif;"}}:null,{tag:"SPAN",attributes:{class:V}}),this.focus()},ct.setFontSize=function(e){return this.changeFormat(e?{tag:"SPAN",attributes:{class:$,style:"font-size: "+("number"==typeof e?e+"px":e)}}:null,{tag:"SPAN",attributes:{class:$}}),this.focus()},ct.setTextColour=function(e){return this.changeFormat(e?{tag:"SPAN",attributes:{class:Q,style:"color:"+e}}:null,{tag:"SPAN",attributes:{class:Q}}),this.focus()},ct.setHighlightColour=function(e){return this.changeFormat(e?{tag:"SPAN",attributes:{class:j,style:"background-color:"+e}}:e,{tag:"SPAN",attributes:{class:j}}),this.focus()},ct.setTextAlignment=function(e){return this.forEachBlock(function(t){var n=t.className.split(/\s+/).filter(function(e){return!!e&&!/^align/.test(e)}).join(" ");e?(t.className=n+" align-"+e,t.style.textAlign=e):(t.className=n,t.style.textAlign="")},!0),this.focus()},ct.setTextDirection=function(e){return this.forEachBlock(function(t){e?t.dir=e:t.removeAttribute("dir")},!0),this.focus()},ct.removeAllFormatting=function(e){if(!e&&!(e=this.getSelection())||e.collapsed)return this;for(var t=this._root,n=e.commonAncestorContainer;n&&!s(n);)n=n.parentNode;if(n||(Me(e,t),n=t),n.nodeType===F)return this;this.saveUndoState(e),Re(e,n);for(var o,i,r=n.ownerDocument,a=e.startContainer,d=e.startOffset,l=e.endContainer,c=e.endOffset,h=r.createDocumentFragment(),u=r.createDocumentFragment(),f=b(l,c,n,t),p=b(a,d,n,t);p!==f;)o=p.nextSibling,h.appendChild(p),p=o;return P(this,h,u),u.normalize(),p=u.firstChild,o=u.lastChild,i=n.childNodes,p?(n.insertBefore(u,f),d=me.call(i,p),c=me.call(i,o)+1):(d=me.call(i,f),c=d),e.setStart(n,d),e.setEnd(n,c),k(n,e),De(e),this.setSelection(e),this._updatePath(e,!0),this.focus()},ct.increaseQuoteLevel=Ot("modifyBlocks",_t),ct.decreaseQuoteLevel=Ot("modifyBlocks",Nt),ct.makeUnorderedList=Ot("modifyBlocks",Tt),ct.makeOrderedList=Ot("modifyBlocks",bt),ct.removeList=Ot("modifyBlocks",Et),ct.increaseListLevel=Ot("modifyBlocks",kt),ct.decreaseListLevel=Ot("modifyBlocks",Bt),O.isInline=a,O.isBlock=s,O.isContainer=d,O.getBlockWalker=l,O.getPreviousBlock=c,O.getNextBlock=h,O.areAlike=u,O.hasTagAttributes=f,O.getNearest=p,O.isOrContains=g,O.detach=C,O.replaceWith=_,O.empty=N,O.getNodeBefore=Ee,O.getNodeAfter=ke,O.insertNodeInRange=Be,O.extractContentsOfRange=xe,O.deleteContentsOfRange=Le,O.insertTreeFragmentIntoRange=Ae,O.isNodeContainedInRange=Oe,O.moveRangeBoundariesDownTree=De,O.moveRangeBoundariesUpTree=Re,O.getStartBlockOfRange=Ue,O.getEndBlockOfRange=Pe,O.contentWalker=Ie,O.rangeDoesStartAtBlockBoundary=we,O.rangeDoesEndAtBlockBoundary=Fe,O.expandRangeToBlockBoundaries=Me,O.onPaste=dt,O.addLinks=Lt,O.splitBlock=Ct,O.startSelectionId=gt,O.endSelectionId=mt,"object"==typeof exports?module.exports=O:"function"==typeof define&&define.amd?define(function(){return O}):(X.Squire=O,top!==X&&"true"===e.documentElement.getAttribute("data-squireinit")&&(X.editor=new O(e),X.onEditorLoad&&(X.onEditorLoad(X.editor),X.onEditorLoad=null)))}(document);
\ No newline at end of file