@livingdocs/editable.js 5.0.3 → 5.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editable.js +1 -1
- package/dist/editable.js.map +1 -1
- package/package.json +4 -4
- package/src/selection-watcher.js +1 -1
package/dist/editable.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Editable=t():e.Editable=t()}(self,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.d(t,{Editable:()=>xi});var n={};e.r(n),e.d(n,{getHost:()=>D,getNodeIndex:()=>F,isBeginningOfHost:()=>U,isDocumentFragmentWithoutChildren:()=>Z,isEndOfHost:()=>z,isEndOffset:()=>K,isInlineElement:()=>ee,isLinebreak:()=>W,isSameNode:()=>G,isStartOffset:()=>$,isTextEndOfHost:()=>Q,isTextEndOffset:()=>X,isVoid:()=>H,isVoidTextNode:()=>P,isWhitespaceOnly:()=>V,lastChild:()=>Y,lastOffsetWithContent:()=>q,latestChild:()=>J});var r={};function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(e){var t=function(e,t){if("object"!=o(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:String(t)}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}function u(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}e.r(r),e.d(r,{adoptElement:()=>we,areSameAttributes:()=>_e,cleanInternals:()=>me,cloneRangeContents:()=>Se,containsString:()=>Ge,createFragmentFromString:()=>Ce,deleteCharacter:()=>Xe,expandTo:()=>De,extractContent:()=>be,forceWrap:()=>Pe,getAncestorTags:()=>xe,getContainedTags:()=>Re,getInnerHtmlOfFragment:()=>ke,getInnerTags:()=>je,getTagNames:()=>Be,getTags:()=>Te,getTagsByName:()=>Ne,getTagsByNameAndAttributes:()=>Oe,insertCharacter:()=>Ke,isAffectedBy:()=>Le,isExactSelection:()=>Ie,isWrappable:()=>He,normalizeTags:()=>pe,normalizeWhitespace:()=>ye,nuke:()=>ze,nukeElem:()=>$e,nukeTag:()=>Ye,removeFormatting:()=>Ue,removeFormattingElem:()=>qe,selectNodeContents:()=>Me,surround:()=>Qe,tidyHtml:()=>ve,toggleTag:()=>Fe,unwrap:()=>We,unwrapInternalNodes:()=>Ee,wrap:()=>Ve});const c={log:!1,logErrors:!0,editableClass:"js-editable",editableDisabledClass:"js-editable-disabled",pastingAttribute:"data-editable-is-pasting",trimLeadingAndTrailingWhitespaces:!0,boldMarkup:{type:"tag",name:"strong",attribs:{},trim:!0},italicMarkup:{type:"tag",name:"em",attribs:{},trim:!0},underlineMarkup:{type:"tag",name:"u",attribs:{},trim:!1},linkMarkup:{type:"tag",name:"a",attribs:{},trim:!0},pastedHtmlRules:{allowedElements:{a:{href:!0,rel:!0,target:!0},strong:{},em:{},br:{}},allowedPlainTextElements:{br:{}},requiredAttributes:{a:["href"]},transformElements:{b:"strong",i:"em"},splitIntoBlocks:["h1","h2","h3","h4","h5","h6","p","blockquote"],blockLevelElements:["h1","h2","h3","h4","h5","h6","div","p","pre","hr","blockquote","article","figure","header","footer","ul","ol","li","section","table","video"],blacklistedElements:["style","script"],keepInternalRelativeLinks:!1,replaceQuotes:{}}};function l(){if(!1!==c.logErrors){var t=1===arguments.length?arguments[0]:Array.from(arguments);if(e.g.console)return"function"==typeof console.error?console.error(t):void console.log(t)}}var f=Object.prototype.toString,h={"&":"&","<":"<",">":">",'"':""","'":"'"};function d(e){return e.replace(/\s+$/,"")}function g(e){return e.replace(/^\s+|\s+$/g,"")}function v(e){return"[object String]"===f.call(e)}var p=1,y=3,m=11,b=function(e){function t(e,n){i(this,t),this.current=this.previous=this.nextNode=this.root=e,this.iteratorFunc=this[n||"getNext"]}return u(t,[{key:Symbol.iterator,value:function(){return this}},{key:"getNextTextNode",value:function(){for(var e;e=this.getNext();)if(e.nodeType===y&&""!==e.data)return e}},{key:"getPreviousTextNode",value:function(){for(var e;e=this.getPrevious();)if(e.nodeType===y&&""!==e.data)return e}},{key:"next",value:function(){var e=this.iteratorFunc();return e?{value:e}:{done:!0}}},{key:"getNext",value:function(){var e=this.current=this.nextNode,t=this.nextNode=void 0;if(this.current)if((t=e.firstChild)&&"remove"!==e.getAttribute("data-editable"))this.nextNode=t;else for(;e!==this.root&&!(this.nextNode=e.nextSibling);)e=e.parentNode;return this.current}},{key:"getPrevious",value:function(){var e=this.current=this.previous,t=this.previous=void 0;if(this.current)if((t=e.lastChild)&&"remove"!==e.getAttribute("data-editable"))this.previous=t;else for(;e!==this.root&&!(this.previous=e.previousSibling);)e=e.parentNode;return this.current}},{key:"replaceCurrent",value:function(e){this.current=e,this.nextNode=void 0,this.previous=void 0;for(var t=this.current;t!==this.root&&!(this.nextNode=t.nextSibling);)t=t.parentNode}}]),t}(),k=function(e,t){return"string"==typeof e?Array.from(t.querySelectorAll(e)):e.tagName?[e]:Array.isArray(e)?e:Array.from(e)},C=function(e,t){return"string"==typeof e?t.querySelector(e):e.tagName?e:e[0]?e[0]:e},w=function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return t.innerHTML=e,t.firstElementChild},S=function(e,t){if(e.closest||(e=e.parentNode),e&&e.closest)return e.closest(t)},A=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).document.createRange()},E=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).document.getSelection()},T=function(e,t,n){for(var r,i=[],o=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:window).document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ALL,{acceptNode:function(r){return e.intersectsNode(r)&&t.includes(r.nodeType)&&r!==e.commonAncestorContainer?"function"==typeof n?n(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}},!1);r=o.nextNode();)i.push(r);return i},x=function(e){e.startContainer.compareDocumentPosition(e.endContainer)===Node.DOCUMENT_POSITION_FOLLOWING&&e.setStartBefore(e.endContainer),e.endContainer.compareDocumentPosition(e.startContainer)===Node.DOCUMENT_POSITION_PRECEDING&&e.setEndAfter(e.startContainer)},N=function(e,t){var n=document.createRange();n.selectNodeContents(t);var r=e.compareBoundaryPoints(Range.START_TO_START,n),i=e.compareBoundaryPoints(Range.END_TO_END,n);return r<=0&&i>=0},O=function(e){return e&&(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE)},_=function(e,t){return e.splitText(t)},j=function(e){var t=e.startContainer,n=e.startOffset,r=e.endContainer,i=e.endOffset;if(O(r)&&i>0&&i<r.length&&_(r,i),O(t)&&n>0&&n<t.length){var o=_(t,n);e.setStart(o,0)}},R=function(e,t){var n=e.cloneRange();n.setStart(t,0),n.setEnd(e.startContainer,e.startOffset);var r=e.toString(),i=n.toString().length;return{start:i,end:i+r.length,text:r}},B=function(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset};function L(e){var t=e.root,n=e.startContainer,r=e.startOffset,i=e.whitespacesOnTheLeft;if(n.nodeType!==y)return L({root:t,startContainer:n.childNodes[r],startOffset:0,whitespacesOnTheLeft:i});var o=r+i;if(n.length>o)return[n,o];var a=new b(t);a.nextNode=n,a.getNextTextNode();var s=a.getNextTextNode();if(!s){var u=a.getPreviousTextNode();return[u,u.length]}return L({root:t,startContainer:s,startOffset:0,whitespacesOnTheLeft:o-n.length})}function M(e){var t=e.root,n=e.endContainer,r=e.endOffset,i=e.whitespacesOnTheRight;if(n.nodeType!==y){var o=!n.childNodes[r-1],a=o?n.childNodes[r]:n.childNodes[r-1],s=0;return o||(s=a.nodeType===y?a.length:a.childNodes.length),M({root:t,endContainer:a,endOffset:s,whitespacesOnTheRight:i})}var u=r-i;if(u>0)return[n,u];var c=new b(t);c.previous=n,c.getPreviousTextNode();var l=c.getPreviousTextNode();return l?M({root:t,endContainer:l,endOffset:l.length,whitespacesOnTheRight:i-r}):[c.getNextTextNode(),0]}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function D(e){return e=e.jquery?e[0]:e,S(e,".".concat(c.editableClass))}function F(e){for(var t=0;null!==(e=e.previousSibling);)t++;return t}function H(e){var t,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return I(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?I(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(e.childNodes);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r.nodeType===y&&!P(r))return!1;if(r.nodeType===p)return!1}}catch(e){n.e(e)}finally{n.f()}return!0}function P(e){return e.nodeType===y&&!e.nodeValue}function V(e){return e.nodeType===y&&0===q(e)}function W(e){return e.nodeType===p&&"BR"===e.tagName}function q(e){if(e.nodeType===y)return d(e.nodeValue).length;var t=0;return Array.from(e.childNodes).reverse().every((function(e,n,r){return!(!V(e)&&!W(e)&&(t=r.length-n,1))})),t}function U(e,t,n){if(t===e)return $(t,n);if($(t,n)){var r=F(t);return U(e,t.parentNode,r)}return!1}function z(e,t,n){if(t===e)return K(t,n);if(K(t,n)){var r=F(t)+1;return z(e,t.parentNode,r)}return!1}function $(e,t){return e.nodeType===y?0===t:0===e.childNodes.length||1===e.childNodes.length&&e.firstChild.nodeType===p&&"remove"===e.firstChild.getAttribute("data-editable")||e.childNodes[t]===e.firstChild}function K(e,t){return e.nodeType===y?t===e.length:0===e.childNodes.length||t>0&&e.childNodes[t-1]===e.lastChild}function Q(e,t,n){if(t===e)return X(t,n);if(X(t,n)){var r=F(t)+1;return Q(e,t.parentNode,r)}return!1}function X(e,t){return e.nodeType===y?t>=d(e.nodeValue).length:0===e.childNodes.length||t>=q(e)}function G(e,t){var n,r,i;if(e.nodeType!==t.nodeType)return!1;if(e.nodeName!==t.nodeName)return!1;for(n=0,r=e.attributes.length;n<r;n++)if(i=e.attributes[n],t.getAttribute(i.name)!==i.value)return!1;return!0}function Y(e){return e.lastChild?Y(e.lastChild):e}function J(e){return console.warn("Editable.js: Using obsolete function parser.latestCild(), use lastChild() instead"),Y(e)}function Z(e){return e&&e.nodeType===m&&0===e.childNodes.length}function ee(e,t){switch((t.currentStyle||e.getComputedStyle(t,"")).display){case"inline":case"inline-block":return!0;default:return!1}}var te=0,ne="\ufeff";function re(e,t){var n=e.commonAncestorContainer;if(3===n.nodeType)return!1;var r=t.parentElement;return(null==r?void 0:r.parentElement)===n}function ie(e,t){var n=e.commonAncestorContainer;n.ownerDocument||l("Cannot save range: range is empty");var r=n.ownerDocument.defaultView.document,i=r.createElement("span");i.id="editable-range-boundary-".concat(++te),i.setAttribute("data-editable","remove"),i.style.lineHeight="0",i.style.display="none",i.appendChild(r.createTextNode(ne));var o=t&&re(e,e.startContainer),a=!t&&re(e,e.endContainer);if(o){var s=e.startContainer.parentElement;s.parentElement.insertBefore(i,s)}else if(a){var u=e.endContainer.parentElement;u.parentElement.insertBefore(i,u.nextSibling)}else{var c=e.cloneRange();c.collapse(t),c.insertNode(i)}return i}function oe(e,t,n,r){var i=ue(e,n);if(!i)return console.log("Marker element has been removed. Cannot restore selection.");t[r?"setStartBefore":"setEndBefore"](i),i.remove()}function ae(e){var t,n,r;return e.collapsed?t={markerId:(r=ie(e,!1)).id,collapsed:!0}:(r=ie(e,!1),t={startMarkerId:(n=ie(e,!0)).id,endMarkerId:r.id,collapsed:!1}),e.collapsed?(e.setStartBefore(r),e.collapse(!0)):(e.setEndBefore(r),e.setStartAfter(n)),t}function se(e,t){if(!t.restored){var n=A();if(t.collapsed){var r=ue(e,t.markerId);if(r){r.style.display="inline";var i=r.previousSibling;i&&i.nodeType===y?(r.remove(),n.setStart(i,i.length)):(n.setStartBefore(r),n.collapse(!0),r.remove())}else console.log("Marker element has been removed. Cannot restore selection.")}else oe(e,n,t.startMarkerId,!0),oe(e,n,t.endMarkerId,!1);return x(n),n}}function ue(e,t){return e.querySelector("#".concat(t))}function ce(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return le(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?le(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function le(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function fe(e,t,n){return t=ae(t),n(),se(e,t)}var he=/\u200B/g,de=/\uFEFF/g,ge=/[^\S ]/g;function ve(e){pe(e)}function pe(e){var t=document.createDocumentFragment();Ae(e,"firstChild"),Ae(e,"lastChild");var n,r=ce(e.childNodes);try{for(r.s();!(n=r.n()).done;){var i=n.value;if("BR"===i.nodeName||i.textContent){if(i.nodeType===p&&"BR"!==i.nodeName){for(var o=i;null!==(o=o.nextSibling)&&G(o,i);){var a,s=ce(o.childNodes);try{for(s.s();!(a=s.n()).done;){var u=a.value;i.appendChild(u.cloneNode(!0))}}catch(e){s.e(e)}finally{s.f()}o.remove()}pe(i)}t.appendChild(i.cloneNode(!0))}}}catch(e){r.e(e)}finally{r.f()}for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(t)}function ye(e){return e.replace(ge," ")}function me(e){e.innerHTML=be(e,!0)}function be(e,t){var n=(e.nodeType===m?ke(e):e.innerHTML).replace(de,"").replace(he,"<br>"),r=document.createElement("div");return r.innerHTML=n,Ee(r,t),Ae(r,"firstChild"),Ae(r,"lastChild"),r.innerHTML}function ke(e){var t=document.createElement("div");return t.appendChild(e),t.innerHTML}function Ce(e){var t=document.createElement("div");t.innerHTML=e;for(var n=document.createDocumentFragment();t.firstChild;)n.appendChild(t.firstChild);return n}function we(e,t){return e.ownerDocument!==t?t.adoptNode(e):e}function Se(e){for(var t=e.cloneContents().childNodes[0],n=document.createDocumentFragment();t.childNodes.length;)n.appendChild(t.childNodes[0]);return n}function Ae(e,t){for(var n,r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];r=e[t];)if(r.nodeType===y){if(!/^\s+$/.test(r.textContent))break;e.removeChild(r)}else{if("BR"!==r.nodeName){r[t]&&Ae(r,t,!1);break}r.remove()}i&&(null===(n=r=e[t])||void 0===n?void 0:n.nodeType)===y&&c.trimLeadingAndTrailingWhitespaces&&(r.textContent=r.textContent.replace(t.startsWith("last")?/ +$/:/^ +/,""))}function Ee(e,t){for(;e;){var n=e.nextSibling;if(e.nodeType===p){var r=e.getAttribute("data-editable");e.firstChild&&Ee(e.firstChild,t),("remove"===r||"ui-remove"===r&&!t)&&e.remove(),("unwrap"===r||"ui-unwrap"===r&&!t)&&We(e),e=n}else e=n}}function Te(e,t,n){var r=je(t,n),i=xe(e,t,n);return r.concat(i)}function xe(e,t,n){for(var r=[],i=t.commonAncestorContainer;i!==e;)n&&!n(i)||r.push(i),i=i.parentNode;return r}function Ne(e,t,n){return Te(e,t,(function(e){return e.nodeName.toUpperCase()===n.toUpperCase()}))}function Oe(e,t,n){return Te(e,t,(function(e){return e.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&_e(e.attributes,n.attributes)}))}function _e(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=t[e[n].name];if(!r||r.value!==e[n].value)return!1}return!0}function je(e,t){return T(e,[p],t)}function Re(e,t){return T(e,[p],t).filter((function(t){return N(e,t)}))}function Be(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((function(e){return e.nodeName}))}function Le(e,t,n){return Te(e,t).some((function(e){return e.nodeName===n.toUpperCase()}))}function Me(e){var t=A();return t.selectNodeContents(e),t}function Ie(e,t,n){var r,i,o=A();if(o.selectNodeContents(t),i=o,-1!==(r=e).compareBoundaryPoints(Range.END_TO_START,i)||-1!==i.compareBoundaryPoints(Range.END_TO_START,r))return!1;var a=e.toString(),s=(t.jquery?t[0]:t).textContent;return n&&(a=g(a),s=g(s)),""!==a&&a===s}function De(e,t,n){return t.selectNodeContents(n),t}function Fe(e,t,n){var r=Oe(e,t,n);return 1===r.length&&Ie(t,r[0],"visible")?qe(e,t,n):Pe(e,t,n)}function He(e){return function(e){if(!e||!e.startContainer||!e.endContainer)return!1;if(e.startContainer===e.endContainer)return!0;for(var t,n=function(e,t){var n=e,r=null;return{next:function(){if(!n)return null;if(n.firstChild&&r!==n.firstChild)r=n,n=n.firstChild;else if(n.nextSibling)r=n,n=n.nextSibling;else{for(var t=n.parentNode;t&&t!==e;){if(t.nextSibling){r=n=t.nextSibling;break}t=t.parentNode}t&&t!==e||(r=n=null)}return n}}}(e.commonAncestorContainer),r=!1;t=n.next();)if(t.nodeType===Node.ELEMENT_NODE&&!Je(t,e)){r=!0;break}return!r}(e)}function Pe(e,t,n){var r=fe(e,t,(function(){$e(e,t,n)}));return He(r)||(r=fe(e,r,(function(){ze(e,r)}))),Ve(r,n),r}function Ve(e,t){He(e)?("string"==typeof t&&(t=w(t)),e.surroundContents(t)):console.log("content.wrap(): can not surround range")}function We(e){for(var t=(e=e.jquery?e[0]:e).parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}function qe(e,t,n){return fe(e,t,(function(){$e(e,t,n)}))}function Ue(e,t,n){return fe(e,t,(function(){ze(e,t,n)}))}function ze(e,t,n){Te(e,t).forEach((function(e){"BR"===e.nodeName.toUpperCase()||n&&!e.matches(n)||We(e)}))}function $e(e,t,n){Te(e,t).forEach((function(e){"BR"!==e.nodeName.toUpperCase()&&(!n||e.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&_e(e.attributes,n.attributes))&&We(e)}))}function Ke(e,t,n){var r=document.createTextNode(t),i=e.cloneRange();i.collapse(n),i.insertNode(r),e[n?"setStartBefore":"setEndAfter"](r),x(e)}function Qe(e,t,n,r){return Ke(t,r||n,!1),Ke(t,n,!0),t}function Xe(e,t,n){if(!Ge(t,n))return t;window.getSelection().rangeCount>0&&j(t);var r=fe(e,t,(function(){T(t,[y],(function(e){return e.nodeValue.indexOf(n)>=0})).forEach((function(e){e.nodeValue=e.nodeValue.replaceAll(n,"")}))}));return x(r),r}function Ge(e,t){return e.toString().indexOf(t)>=0}function Ye(e,t,n){Te(e,t).forEach((function(e){e.nodeName.toUpperCase()===n.toUpperCase()&&We(e)}))}function Je(e,t){var n=document.createRange();return n.selectNodeContents(e),t.compareBoundaryPoints(Range.START_TO_START,n)<=0&&t.compareBoundaryPoints(Range.END_TO_END,n)>=0}var Ze=1,et={},tt=ot("nextElementSibling"),nt=ot("previousElementSibling");function rt(e,t){var n=t.normalize,r=t.plainText,i=t.shouldSpellcheck;!function(e){e.hasAttribute("data-editable")||(e.setAttribute("data-editable","id-".concat(Ze)),Ze+=1)}(e),e.setAttribute("contenteditable",!0),e.setAttribute("spellcheck",Boolean(i)),e.setAttribute("data-plaintext",Boolean(r)),e.classList.remove(c.editableDisabledClass),e.classList.add(c.editableClass),n&&ve(e)}function it(e){return"true"===e.getAttribute("data-plaintext")}function ot(e){return function(t){var n=t[e];return n&&n.getAttribute("contenteditable")?n:null}}function at(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function st(e,t){if(e){if("string"==typeof e)return at(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?at(e,t):void 0}}function ut(e){return function(e){if(Array.isArray(e))return at(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||st(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ct,lt,ft,ht,dt,gt,vt,pt,yt,mt=[["«","»"],["»","«"],['"','"'],["“","”"],["”","”"],["“","“"],["„","“"]],bt=[["‘","’"],["‹","›"],["‚","‘"],["’","’"],["›","‹"],["'","'"],["‘","’"]],kt=["’","'"],Ct=/([‘’‹›‚'«»"“”„])(?![^<]*?>)/g,wt=/\s|[>\-–—«»”"“„]/,St=/\s|[<\-–—«»”"“‘’‹›'.;?:,]/;function At(e,t){(ct=t||{}).quotes=ct.quotes||[void 0,void 0],ct.singleQuotes=ct.singleQuotes||[void 0,void 0];var n=function(e){return ut(e.matchAll(Ct)).map((function(t){var n=t.index;return{char:t[1],before:n>0?e[n-1]:"",after:n+1<e.length?e[n+1]:""}}))}(e);return n.length>0?(Et(n,0),function(e,t){var n=0;return e.replace(Ct,(function(e){var r=t[n].replace||t[n].char;return n+=1,r}))}(e,n)):e}function Et(e,t){for(;t<e.length;){var n=Tt(e,t);if(n){if(e[t].replace="double"===n.type?ct.quotes[0]:ct.singleQuotes[0],e[n.position].replace="double"===n.type?ct.quotes[1]:ct.singleQuotes[1],n.position!==t+1){var r=e.slice(t+1,n.position);r&&Et(r,0)}t=n.position+1}else e[t].replace=Nt(e[t].char),t+=1}}function Tt(e,t){if(t!==e.length-1){var n=e[t],r=n.char;if(!n.before||wt.test(n.before))for(var i=xt(r,bt),o=xt(r,mt),a=t+1;a<e.length;a++)if(e[a].after&&St.test(e[a].after)||!e[a].after){if(i.includes(e[a].char))return{position:a,type:"single"};if(o.includes(e[a].char))return{position:a,type:"double"}}}}function xt(e,t){return t.filter((function(t){return t[0]===e})).map((function(e){return e[1]}))}function Nt(e){if(kt.includes(e))return ct.apostrophe}var Ot,_t=/^\s*$/,jt="\x3c!-- BLOCK --\x3e";function Rt(e){var t=e.pastedHtmlRules;lt=t.allowedElements||{},ft=t.allowedPlainTextElements||{},ht=t.requiredAttributes||{},dt=t.transformElements||{},yt=t.blacklistedElements||[],Ot=t.keepInternalRelativeLinks||!1,vt=t.replaceQuotes||{},gt={},t.blockLevelElements.forEach((function(e){gt[e]=!0})),pt={},t.splitIntoBlocks.forEach((function(e){pt[e]=!0}))}function Bt(e,t,n){var r=e.ownerDocument;e.setAttribute(c.pastingAttribute,!0),t.isSelection&&(t=t.deleteExactSurroundingTags().deleteContainedTags().deleteContent());var i=r.createElement("div");i.innerHTML=n;var o=function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).plainText,n=void 0!==t&&t;return Lt(e,{allowedElements:n?ft:lt,keepInternalRelativeLinks:!n&&Ot}).split(jt).map((function(e){return g((t=e,vt.quotes||vt.singleQuotes||vt.apostrophe?At(t,vt):t).replace(/\n/g," ").replace(/ {2,}/g," ").replace(/(.)\u00A0/g,(function(e,t){return t+(/[\u0020]/.test(t)?" ":" ")})));var t})).filter((function(e){return!_t.test(e)}))}(i,{plainText:it(e)});return e.removeAttribute(c.pastingAttribute),{blocks:o,cursor:t}}function Lt(e,t){return Array.from(e.childNodes).reduce((function(e,n){if(-1!==yt.indexOf(n.nodeName.toLowerCase()))return"";if(t.keepInternalRelativeLinks&&"A"===n.nodeName&&n.href){var r=n.getAttribute("href").replace(window.location.origin,"");n.setAttribute("href",r)}return n.nodeType===p?e+function(e,t,n){var r=e.nodeName.toLowerCase();if(function(e,t,n){return n.allowedElements[e]&&function(e,t){var n=ht[e];return!n||!n.some((function(e){return!t.getAttribute(e)}))}(e,t)}(r=function(e){return dt[e]||e}(r),e,n)){var i=function(e,t){return Array.from(t.attributes).reduce((function(t,n){var r=n.name,i=n.value;return lt[e][r]&&i?"".concat(t," ").concat(r,'="').concat(i,'"'):t}),"")}(r,e);return"br"===r?"<".concat(r+i,">"):_t.test(t)?t:"<".concat(r+i,">").concat(t,"</").concat(r,">")}return pt[r]?jt+t+jt:gt[r]?"".concat(t," "):t}(n,Lt(n,t),t):n.nodeType===y?e+n.nodeValue.replace(/[&<>]/g,(function(e){return h[e]})):e}),"")}Rt(c),document.documentElement.contentEditable;var Mt=/(apple)?webkit\/537\.36/i.test(window.navigator.userAgent),It=/(apple)?webkit/i.test(window.navigator.userAgent),Dt=!Mt&&It,Ft=function(e){var t=e,n=t.onselectionchange;if(void 0!==n)try{return t.onselectionchange=0,null===t.onselectionchange}catch(e){}finally{t.onselectionchange=n}return!1}(document),Ht=!!Dt;function Pt(e,t){var n=function(e){var t={};function n(e,n){e.split(" ").forEach((function(e){t[e]=t[e]||[],t[e].unshift(n)}))}return{on:function(e,t){if(2===arguments.length)n(e,t);else if(1===arguments.length)for(var r in e)n(r,e[r]);return this},off:function(e,n){2===arguments.length?function(e,n){var r=t[e];if(r){var i=r.indexOf(n);i<0||r.splice(i,1)}}(e,n):1===arguments.length?t[e]=[]:t={}},notify:function(n,r){var i=Array.from(arguments);e?(r=n,n=e,i.splice(0,1)):i.splice(0,2),this.switchContext&&r!==this.switchContext.events.shift()&&(this.switchContext=void 0);var o=t[r];o&&o.every((function(e){return!1!==e.apply(n,i)}))}}}(t);e.on=n.on,e.off=n.off,e.notify=n.notify}function Vt(e){return{x:void 0!==e.pageXOffset?e.pageXOffset:(e.document.documentElement||e.document.body.parentNode||e.document.body).scrollLeft,y:void 0!==e.pageYOffset?e.pageYOffset:(e.document.documentElement||e.document.body.parentNode||e.document.body).scrollTop}}var Wt=function(){function e(t,n){i(this,e),this.setHost(t),this.range=n,this.isCursor=!0}return u(e,[{key:"getTags",value:function(e){return Te(this.host,this.range,e)}},{key:"getTagNames",value:function(e){return Be(this.getTags(e))}},{key:"getTagsByName",value:function(e){return Ne(this.host,this.range,e)}},{key:"getInnerTags",value:function(e){return je(this.range,e)}},{key:"getContainedTags",value:function(e){return Re(this.range,e)}},{key:"getAncestorTags",value:function(e){return xe(this.host,this.range,e)}},{key:"isAtEnd",value:function(){return z(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtTextEnd",value:function(){return Q(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtLastLine",value:function(){var e=this.win.document.createRange();e.selectNodeContents(this.host),e.collapse(!1);var t=qt(e,this.win),n=qt(this.range,this.win);return Ut(t.bottom,n.bottom)}},{key:"isAtFirstLine",value:function(){var e=this.win.document.createRange();e.selectNodeContents(this.host),e.collapse(!0);var t=qt(e,this.win),n=qt(this.range,this.win);return Ut(t.top,n.top)}},{key:"isAtBeginning",value:function(){return U(this.host,this.range.startContainer,this.range.startOffset)}},{key:"insertBefore",value:function(e){if(v(e)&&(e=Ce(e)),!Z(e)){var t=e=this.adoptElement(e);if(e.nodeType===m){var n=e.childNodes.length-1;t=e.childNodes[n]}this.range.insertNode(e),this.range.setStartAfter(t),this.range.setEndAfter(t),this.host.normalize()}}},{key:"insertAfter",value:function(e){if(v(e)&&(e=Ce(e)),!Z(e)){e=this.adoptElement(e);var t=this.range.cloneRange();t.setStart(t.endContainer,t.endOffset),t.collapse(!0),t.insertNode(e),this.host.normalize()}}},{key:"setSelection",value:function(){this.setVisibleSelection()}},{key:"setVisibleSelection",value:function(){if(this.win.document.activeElement!==this.host){var e=Vt(this.win),t=e.x,n=e.y;this.win.scrollTo(t,n)}var r=E(this.win);r.removeAllRanges(),r.addRange(this.range)}},{key:"before",value:function(){var e=this.range.cloneRange();return e.collapse(!0),e.setStartBefore(this.host),Se(e)}},{key:"textBefore",value:function(){var e=this.range.cloneRange();return e.collapse(!0),e.setStartBefore(this.host),e.toString()}},{key:"beforeHtml",value:function(){return ke(this.before())}},{key:"after",value:function(){var e=this.range.cloneRange();return e.collapse(!1),e.setEndAfter(this.host),Se(e)}},{key:"textAfter",value:function(){var e=this.range.cloneRange();return e.collapse(!1),e.setEndAfter(this.host),e.toString()}},{key:"afterHtml",value:function(){return ke(this.after())}},{key:"getBoundingClientRect",value:function(){return this.range.getBoundingClientRect()}},{key:"getCoordinates",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"absolute",t=this.range.getBoundingClientRect();if("fixed"===e)return t;var n=Vt(this.win),r=n.x,i=n.y;return{top:t.top+i,bottom:t.bottom+i,left:t.left+r,right:t.right+r,height:t.height,width:t.width}}},{key:"moveBefore",value:function(t){if(this.updateHost(t),this.range.setStartBefore(t),this.range.setEndBefore(t),this.isSelection)return new e(this.host,this.range)}},{key:"moveAfter",value:function(t){if(this.updateHost(t),this.range.setStartAfter(t),this.range.setEndAfter(t),this.isSelection)return new e(this.host,this.range)}},{key:"moveAtBeginning",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(t),this.range.selectNodeContents(t),this.range.collapse(!0),this.isSelection)return new e(this.host,this.range)}},{key:"moveAtEnd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(t),this.range.selectNodeContents(t),this.range.collapse(!1),this.isSelection)return new e(this.host,this.range)}},{key:"moveAtTextEnd",value:function(e){return this.moveAtEnd(Y(e))}},{key:"setHost",value:function(e){e.jquery&&(e=e[0]),this.host=e,this.win=null==e?window:e.ownerDocument.defaultView}},{key:"updateHost",value:function(e){var t=D(e);t||l("Can not set cursor outside of an editable block"),this.setHost(t)}},{key:"retainVisibleSelection",value:function(e){this.save(),e(),this.restore(),this.setVisibleSelection()}},{key:"save",value:function(){this.savedRangeInfo=ae(this.range),this.savedRangeInfo.host=this.host}},{key:"restore",value:function(){this.savedRangeInfo||l("Could not restore selection"),this.host=this.savedRangeInfo.host,this.range=se(this.host,this.savedRangeInfo),this.savedRangeInfo=void 0}},{key:"equals",value:function(e){return!!(e&&e.host&&e.host.isEqualNode(this.host)&&e.range&&B(e.range,this.range))}},{key:"createElement",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.win.document.createElement(e);for(var r in t){var i=t[r];n.setAttribute(r,i)}return n}},{key:"createTextNode",value:function(e){return this.win.document.createTextNode(e)}},{key:"adoptElement",value:function(e){return we(e,this.win.document)}},{key:"triggerChange",value:function(){var e=new Event("formatEditable",{bubbles:!0,cancelable:!1});this.host.dispatchEvent(e)}}],[{key:"findHost",value:function(e,t){return S(e,t)}}]),e}();function qt(e,t){if(e.startContainer.nodeType!==p)return e.getBoundingClientRect();var n=t.document.createElement("span");n.setAttribute("doc-editable","unwrap"),e.insertNode(n);var r=n.getBoundingClientRect();return n.remove(),r}function Ut(e,t){return e===t||Math.abs(e-t)<=2}function zt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||st(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $t(e){return $t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},$t(e)}function Kt(e,t){return Kt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Kt(e,t)}const Qt={extractText:function(e){var t="";return function(e,t,n){for(var r,i=new b(e);r=i.getNext();)r.nodeType===y&&""!==r.data?n(r.data):t&&r.nodeType===p&&"BR"===r.nodeName&&n("\n")}(e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],(function(e){t+=e})),t},highlightMatches:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(t&&0!==t.length){e.normalize();for(var r,i,o,a=new b(e),s=0,u=0,c=t[s],l=[];r=a.getNext();)if(r.nodeType===y&&""!==r.data){var f=(o=r).data,h=u+f.length;if(c.startIndex<h&&u<c.endIndex){var d=u<=c.startIndex,g=h>=c.endIndex;d&&(i=c.id||c.startIndex);var v;v=d?c.startIndex-u:0;var m;m=g?c.endIndex-u-v:f.length-v;var k={element:o,text:f.substring(v,v+m),offset:v,length:m,isLastPortion:g,wordId:i};if(l.push(k),g){var C=this.wrapMatch(l,c.marker,c.title);a.replaceCurrent(C),h=u+k.length+k.offset,l=[],(s+=1)<t.length&&(c=t[s])}}u=h}else if(n&&r.nodeType===p&&"BR"===r.nodeName){u+=1;continue}}},wrapMatch:function(e,t,n){var r=this;return e.map((function(e){return r.wrapPortion(e,t,n)})).pop()},wrapPortion:function(e,t,n){var r=A();r.setStart(e.element,e.offset),r.setEnd(e.element,e.offset+e.length);var i=t.cloneNode(!0);if(i.setAttribute("data-word-id",e.wordId),n&&i.setAttribute("title",n),r.surroundContents(i),i.nextSibling){var o=i.nextSibling;o.nodeType===y&&""===o.data&&o.remove()}return i}};function Xt(e,t,n,r){if(!e||""===e)return[];if(r&&!function(e){try{var t;return!!e&&e instanceof(null===(t=e.ownerDocument)||void 0===t?void 0:t.defaultView.HTMLElement)}catch(t){return"object"===o(e)&&1===e.nodeType&&"object"===o(e.style)&&"object"===o(e.ownerDocument)}}(r))return[];if(null==t||!t.length)return[];var i=("word"===n?Jt:Gt)(t);return ut(e.matchAll(i)).map((function(e){var t,i;return"word"===n?(t=e.index+e[1].length,i=e[2]):(t=e.index,i=e[0]),{startIndex:t,endIndex:t+i.length,match:i,marker:r}}))}function Gt(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((function(e){return Zt(e)})),t="(".concat(e.join("|"),")");return new RegExp(t,"g")}var Yt="\\u0041-\\u005A\\u0061-\\u007A\\u0030-\\u0039\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u00FF\\u0100-\\u017F\\u0180-\\u024F";function Jt(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((function(e){return Zt(e)})),t="([^".concat(Yt,"]|^)")+"(".concat(e.join("|"),")")+"(?=[^".concat(Yt,"]|$)");return new RegExp(t,"g")}function Zt(e){return String(e).replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function en(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return tn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?tn(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function tn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var nn={highlightText:function(e,t,n,r){if(!this.hasHighlight(e,n)){var i=Qt.extractText(e),o='<span class="highlight-'.concat(r,'"></span>'),a=function(e,t,n){return Xt(e,[t],"text",n)}(i,t,nn.createMarkerNode(o,r,this.win));return a&&a.length?(n&&(a[0].id=n),Qt.highlightMatches(e,a),a[0].startIndex):void 0}},highlightRange:function(e,t,n,r,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"comment";if(this.hasHighlight(e,n)&&this.removeHighlight(e,n),""===Qt.extractText(e,!1))return-1;var s=nn.createMarkerNode('<span class="highlight-'.concat(a,'"></span>'),a,this.win),u=r,c=i;return Qt.highlightMatches(e,[{startIndex:u,endIndex:c,id:n,marker:s}],!1),o&&o.notify("change",e),u},updateHighlight:function(e,t,n,r){if(document.documentElement.classList){var i,o=en(e.querySelectorAll('[data-word-id="'.concat(t,'"]')));try{for(o.s();!(i=o.n()).done;){var a=i.value;r&&a.classList.remove(r),n&&a.classList.add(n)}}catch(e){o.e(e)}finally{o.f()}}},removeHighlight:function(e,t,n){var r,i=en(e.querySelectorAll('[data-word-id="'.concat(t,'"]')));try{for(i.s();!(r=i.n()).done;)We(r.value)}catch(e){i.e(e)}finally{i.f()}e.normalize(),n&&n.notify("change",e)},hasHighlight:function(e,t){return!!e.querySelectorAll('[data-word-id="'.concat(t,'"]')).length},extractHighlightedRanges:function(e,t){var n="[data-word-id]";t&&(n+='[data-highlight="'.concat(t,'"]'));var r=e.querySelectorAll(n);if(r.length){var i,o={},a=en(r);try{for(a.s();!(i=a.n()).done;){var s=i.value.getAttribute("data-word-id");o[s]||(o[s]=e.querySelectorAll('[data-word-id="'.concat(s,'"]')))}}catch(e){a.e(e)}finally{a.f()}var u={};for(var c in o){var l=this.extractMarkerNodePosition(e,o[c]);l&&(u[c]=l)}return u}},extractMarkerNodePosition:function(e,t){var n=A();t.length>1?(n.setStartBefore(t[0]),n.setEndAfter(t[t.length-1])):n.selectNode(t[0]);var r=R(n,e);return{start:r.start,end:r.end,text:r.text,nativeRange:n}},cleanupStaleMarkerNodes:function(e,t){var n,r=en(e.querySelectorAll('span[data-highlight="'.concat(t,'"]')));try{for(r.s();!(n=r.n()).done;){var i=n.value;i.textContent.length||i.remove()}}catch(e){r.e(e)}finally{r.f()}},createMarkerNode:function(e,t,n){var r=w(e,n);return r.setAttribute("data-editable","ui-unwrap"),r.setAttribute("data-highlight",t),r}};const rn=nn;function on(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var an=function(e){function t(){var e;return i(this,t),delete(e=function(e,t,n){return t=$t(t),function(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],$t(e).constructor):t.apply(e,n))}(this,t,arguments)).isCursor,e.isSelection=!0,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Kt(e,t)}(t,e),u(t,[{key:"text",value:function(){return this.range.toString()}},{key:"html",value:function(){return function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return t.appendChild(e.cloneContents()),t.innerHTML}(this.range)}},{key:"isAllSelected",value:function(){return U(this.host,this.range.startContainer,this.range.startOffset)&&Q(this.host,this.range.endContainer,this.range.endOffset)}},{key:"getTextRange",value:function(){return R(this.range,this.host)}},{key:"toString",value:function(){return this.range.toString()}},{key:"isWrappable",value:function(){return He(this.range)}},{key:"getRects",value:function(){return this.range.getClientRects()}},{key:"link",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e&&(t.href=e);var n=this.createElement(c.linkMarkup.name,c.linkMarkup.attribs);for(var r in t){var i=t[r];void 0!==i&&(null===i?n.removeAttribute(r):n.setAttribute(r,i))}c.linkMarkup.trim&&this.trimRange(),this.forceWrap(n)}},{key:"trimRange",value:function(){var e=this.range.toString(),t=e.search(/\S|$/),n=e.search(/\S[\s]+$/),r=-1===n?0:e.length-(n+1),i=zt(L({root:this.range.commonAncestorContainer,startContainer:this.range.startContainer,startOffset:this.range.startOffset,whitespacesOnTheLeft:t}),2),o=i[0],a=i[1];this.range.setStart(o,a);var s=zt(M({root:this.range.commonAncestorContainer,endContainer:this.range.endContainer,endOffset:this.range.endOffset,whitespacesOnTheRight:r}),2),u=s[0],c=s[1];this.range.setEnd(u,c)}},{key:"unlink",value:function(){this.removeFormatting(c.linkMarkup.name)}},{key:"toggleLink",value:function(e,t){var n=this.getTagsByName(c.linkMarkup.name);if(n.length>=1){var r=n[0];this.isExactSelection(r,"visible")?this.unlink():this.expandTo(r)}else this.link(e,t)}},{key:"highlightComment",value:function(e){var t=e.highlightId,n=e.textRange;rn.highlightRange(this.host,t,n.text,n.start,n.end,void 0,"comment")}},{key:"highlight",value:function(e){e.highlightId;var t=this.textBefore(),n=this.text(),r=rn.createMarkerNode('<span class="highlight-comment"></span>',this.win);r.setAttribute("data-match",n);var i={startIndex:t.length,endIndex:t.length+n.length,match:n,marker:r};Qt.highlightMatches(this.host,[i])}},{key:"toggle",value:function(e){it(this.host)||this.range.collapsed||(e=this.adoptElement(e),this.range=Fe(this.host,this.range,e),this.setVisibleSelection())}},{key:"toggleCustom",value:function(e){var t=e.tagName,n=e.attributes,r=e.trim,i=void 0!==r&&r,o=this.createElement(t,n);i&&this.trimRange(),this.toggle(o)}},{key:"makeCustom",value:function(e){var t=e.tagName,n=e.attributes,r=e.trim,i=void 0!==r&&r,o=this.createElement(t,n);i&&this.trimRange(),this.forceWrap(o)}},{key:"makeBold",value:function(){var e=this.createElement(c.boldMarkup.name,c.boldMarkup.attribs);c.boldMarkup.trim&&this.trimRange(),this.forceWrap(e)}},{key:"toggleBold",value:function(){var e=this.createElement(c.boldMarkup.name,c.boldMarkup.attribs);c.boldMarkup.trim&&this.trimRange(),this.toggle(e)}},{key:"giveEmphasis",value:function(){var e=this.createElement(c.italicMarkup.name,c.italicMarkup.attribs);c.italicMarkup.trim&&this.trimRange(),this.forceWrap(e)}},{key:"toggleEmphasis",value:function(){var e=this.createElement(c.italicMarkup.name,c.italicMarkup.attribs);c.italicMarkup.trim&&this.trimRange(),this.toggle(e)}},{key:"makeUnderline",value:function(){var e=this.createElement(c.underlineMarkup.name,c.underlineMarkup.attribs);c.underlineMarkup.trim&&this.trimRange(),this.forceWrap(e)}},{key:"toggleUnderline",value:function(){var e=this.createElement(c.underlineMarkup.name,c.underlineMarkup.attribs);c.underlineMarkup.trim&&this.trimRange(),this.toggle(e)}},{key:"insertCharacter",value:function(e){var t=this.deleteContent(),n=t.createTextNode(e);return t.insertBefore(n),t.setVisibleSelection(),t}},{key:"surround",value:function(e,t){this.range=Qe(this.host,this.range,e,t),this.setVisibleSelection()}},{key:"removeSurround",value:function(e,t){this.range=Xe(this.host,this.range,e),this.range=Xe(this.host,this.range,t),this.setVisibleSelection()}},{key:"removeChars",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=0;t<e.length;t++){var n=e[t];this.range=Xe(this.host,this.range,n)}this.setVisibleSelection()}},{key:"toggleSurround",value:function(e,t){this.containsString(e)&&this.containsString(t)?this.removeSurround(e,t):this.surround(e,t)}},{key:"removeFormatting",value:function(e){this.range=Ue(this.host,this.range,e),this.setVisibleSelection()}},{key:"deleteExactSurroundingTags",value:function(){var e,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return on(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?on(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(this.getAncestorTags().reverse());try{for(n.s();!(e=n.n()).done;){var r=e.value;if(this.isExactSelection(r)){r.remove();break}}}catch(e){n.e(e)}finally{n.f()}return new t(this.host,this.range)}},{key:"deleteContainedTags",value:function(){return this.getContainedTags().forEach((function(e){return e.remove()})),new t(this.host,this.range)}},{key:"deleteContent",value:function(){return this.range.deleteContents(),new Wt(this.host,this.range)}},{key:"expandTo",value:function(e){this.range=De(this.host,this.range,e),this.setVisibleSelection()}},{key:"collapseAtBeginning",value:function(e){return this.range.collapse(!0),this.setVisibleSelection(),new Wt(this.host,this.range)}},{key:"collapseAtEnd",value:function(e){return this.range.collapse(!1),this.setVisibleSelection(),new Wt(this.host,this.range)}},{key:"forceWrap",value:function(e){it(this.host)||this.range.collapsed||(e=this.adoptElement(e),this.range=Pe(this.host,this.range,e),this.setVisibleSelection())}},{key:"isExactSelection",value:function(e,t){return Ie(this.range,e,t)}},{key:"containsString",value:function(e){return Ge(this.range,e)}},{key:"deleteCharacter",value:function(e){this.range=Xe(this.host,this.range,e),this.setVisibleSelection()}}]),t}(Wt),sn=function(){function e(t,n){i(this,e),this.host=t&&t.jquery?t[0]:t,this.range=n,this.isAnythingSelected=void 0!==n,this.isCursor=this.isAnythingSelected&&n.collapsed,this.isSelection=this.isAnythingSelected&&!this.isCursor}return u(e,[{key:"getCursor",value:function(){if(this.isCursor)return new Wt(this.host,this.range)}},{key:"getSelection",value:function(){if(this.isSelection)return new an(this.host,this.range)}},{key:"forceCursor",value:function(){return this.isSelection?this.getSelection().deleteContent():this.getCursor()}},{key:"isDifferentFrom",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new e,n=this.range,r=t.range;return n&&r?!B(n,r):!(!n&&!r)}}]),e}(),un=function(){function e(t,n){i(this,e),this.dispatcher=t,this.win=n||window,this.selection=void 0,this.currentSelection=void 0,this.currentRange=void 0}return u(e,[{key:"syncSelection",value:function(){try{this.selection=E(this.win)}catch(e){return!1}return!0}},{key:"getRangeContainer",value:function(){var e=this.syncSelection();if(this.selection.rangeCount&&e){var t=this.selection.getRangeAt(0),n=D(t.commonAncestorContainer);if(n)return new sn(n,t)}return new sn}},{key:"getFreshRange",value:function(){return this.getRangeContainer()}},{key:"getFreshSelection",value:function(){var e=this.getRangeContainer();return e.isCursor?e.getCursor(this.win):e.getSelection(this.win)}},{key:"getSelection",value:function(){return this.currentSelection}},{key:"forceCursor",value:function(){return this.getRangeContainer().forceCursor()}},{key:"selectionChanged",value:function(){var e=this.getRangeContainer();if(e.isDifferentFrom(this.currentRange)){var t=this.currentSelection;this.currentRange=e,t&&(t.isCursor&&!this.currentRange.isCursor?this.dispatcher.notify("cursor",t.host):t.isSelection&&!this.currentRange.isSelection&&this.dispatcher.notify("selection",t.host)),this.currentRange.isCursor?(this.currentSelection=new Wt(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("cursor",this.currentSelection.host,this.currentSelection)):this.currentRange.isSelection?(this.currentSelection=new an(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("selection",this.currentSelection.host,this.currentSelection)):this.currentSelection=void 0}}}]),e}(),cn=function(){function e(t){i(this,e),Pt(this),this.selectionWatcher=t}return u(e,[{key:"dispatchKeyEvent",value:function(e,t,n){switch(e.keyCode){case this.key.left:return this.notify(t,"left",e);case this.key.right:return this.notify(t,"right",e);case this.key.up:return this.notify(t,"up",e);case this.key.down:return this.notify(t,"down",e);case this.key.tab:return e.shiftKey?this.notify(t,"shiftTab",e):this.notify(t,"tab",e);case this.key.esc:return this.notify(t,"esc",e);case this.key.backspace:return this.preventContenteditableBug(t,e),this.notify(t,"backspace",e);case this.key.delete:return this.preventContenteditableBug(t,e),this.notify(t,"delete",e);case this.key.enter:return e.shiftKey?this.notify(t,"shiftEnter",e):this.notify(t,"enter",e);case this.key.ctrl:case this.key.shift:case this.key.alt:case 224:case 17:case 91:case 93:return;default:if(e.keyCode===this.key.b&&(e.ctrlKey||e.metaKey))return this.notify(t,"bold",e);if(e.keyCode===this.key.i&&(e.ctrlKey||e.metaKey))return this.notify(t,"italic",e);if(this.preventContenteditableBug(t,e),!n)return;if(!e.ctrlKey&&!e.metaKey)return this.notify(t,"character",e)}}},{key:"preventContenteditableBug",value:function(t,n){if(Ht&&!n.ctrlKey&&!n.metaKey){var r=this.selectionWatcher.getFreshRange();if(r.isSelection){var i=e.getNodeToRemove(r.range,t);i&&i.remove()}}}}],[{key:"getNodeToRemove",value:function(t,n){if(0===t.startOffset){var r=t.startContainer;if(r.nodeType===y&&(r=r.parentNode),r!==n){var i=A();if(i.setStartBefore(r.firstChild),i.setEndAfter(r.lastChild),a=t,!((o=i).compareBoundaryPoints(Range.START_TO_START,a)<=0&&o.compareBoundaryPoints(Range.END_TO_END,a)>=0)){var o,a;if(t.startContainer.nodeType===y){var s=[y,p],u=r.firstChild;do{if(-1!==s.indexOf(u.nodeType))break}while(u=u.nextSibling);if(u!==t.startContainer)return}var c=t.cloneRange();return c.setStartBefore(r),e.getNodeToRemove(c,n)||r}}}}}]),e}();function ln(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return fn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fn(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function fn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}cn.key=cn.prototype.key={left:37,up:38,right:39,down:40,tab:9,esc:27,backspace:8,delete:46,enter:13,shift:16,ctrl:17,alt:18,b:66,i:73};var hn=!1,dn=function(){function e(t){i(this,e);var n=t.win;Pt(this,t),this.supportsInputEvent=!1,this.document=n.document,this.config=t.config,this.editable=t,this.editableSelector=t.editableSelector,this.selectionWatcher=new un(this,n),this.keyboard=new cn(this.selectionWatcher),this.activeListeners=[],this.setup(),this.getEditableBlockByEvent=function(e){return S(e.target,t.editableSelector)}}return u(e,[{key:"setupDocumentListener",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r={event:e,listener:t.bind(this),capture:n};return this.activeListeners.push(r),this.document.addEventListener(e,r.listener,n),this}},{key:"setup",value:function(){this.setupKeyboardEvents(),this.setupEventListeners()}},{key:"unload",value:function(){this.off();var e,t=ln(this.activeListeners);try{for(t.s();!(e=t.n()).done;){var n=e.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(e){t.e(e)}finally{t.f()}this.activeListeners.length=0}},{key:"suspend",value:function(){if(!this.suspended){this.suspended=!0;var e,t=ln(this.activeListeners);try{for(t.s();!(e=t.n()).done;){var n=e.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(e){t.e(e)}finally{t.f()}this.activeListeners.length=0}}},{key:"continue",value:function(){this.suspended&&(this.suspended=!1,this.setupEventListeners())}},{key:"setupEventListeners",value:function(){this.setupElementListeners(),this.setupKeydownListener(),Ft?this.setupSelectionChangeListeners():this.setupSelectionChangeFallbackListeners()}},{key:"setupElementListeners",value:function(){this.setupDocumentListener("focus",(function(e){var t=this.getEditableBlockByEvent(e);t&&(e.target.getAttribute(c.pastingAttribute)||(this.selectionWatcher.syncSelection(),this.notify("focus",t)))}),!0).setupDocumentListener("blur",(function(e){var t=this.getEditableBlockByEvent(e);t&&(t.getAttribute(c.pastingAttribute)||this.notify("blur",t))}),!0).setupDocumentListener("copy",(function(e){var t=this.getEditableBlockByEvent(e);if(t){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&this.notify("clipboard",t,"copy",n)}})).setupDocumentListener("cut",(function(e){var t=this.getEditableBlockByEvent(e);if(t){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&(this.notify("clipboard",t,"cut",n),this.triggerChangeEvent(t))}})).setupDocumentListener("paste",(function(e){var t=this.getEditableBlockByEvent(e);if(t){e.preventDefault();var n,r=this.selectionWatcher.getFreshSelection(),i=e.clipboardData.getData("text/html")||e.clipboardData.getData("text/plain"),o=Bt(t,r,i),a=o.blocks,s=o.cursor;a.length?(n=e.target.innerText,/\S+\s{1}$/.test(n)&&s.retainVisibleSelection((function(){t.innerHTML=function(e,t,n){if(!e)return"";var r=(e="".concat(e)).lastIndexOf(t);return-1===r?e:"".concat(e.slice(0,r)).concat(" ").concat(e.slice(r+6))}(t.innerHTML," ")})),this.notify("paste",t,a,s),this.notify("change",t)):s.setVisibleSelection()}})).setupDocumentListener("input",(function(e){var t=this.getEditableBlockByEvent(e);t&&(hn?this.notify("change",t):hn=!0)})).setupDocumentListener("formatEditable",(function(e){var t=this.getEditableBlockByEvent(e);t&&this.notify("change",t)}))}},{key:"triggerChangeEvent",value:function(e){hn||this.notify("change",e)}},{key:"dispatchSwitchEvent",value:function(e,t,n){if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)){var r=this.selectionWatcher.getFreshSelection();r&&!r.isSelection&&(this.switchContext?this.switchContext.events=["cursor"]:this.switchContext={positionX:r.getBoundingClientRect().left,events:["cursor"]},"up"===n&&r.isAtFirstLine()&&(e.preventDefault(),e.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",t,n,r)),"down"===n&&r.isAtLastLine()&&(e.preventDefault(),e.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",t,n,r)))}}},{key:"setupKeydownListener",value:function(){this.setupDocumentListener("keydown",(function(e){var t=this.getEditableBlockByEvent(e);if(t){var n=!hn;this.keyboard.dispatchKeyEvent(e,t,n)}}),!0)}},{key:"setupKeyboardEvents",value:function(){var e=this;this.keyboard.on("up",(function(t){e.dispatchSwitchEvent(t,this,"up")})).on("down",(function(t){e.dispatchSwitchEvent(t,this,"down")})).on("backspace",(function(t){var n=e.selectionWatcher.getFreshRange();if(!n.isCursor)return e.triggerChangeEvent(this);var r=n.getCursor();if(!r.isAtBeginning())return e.triggerChangeEvent(this);t.preventDefault(),t.stopPropagation(),e.notify("merge",this,"before",r)})).on("delete",(function(t){var n=e.selectionWatcher.getFreshRange();if(!n.isCursor)return e.triggerChangeEvent(this);var r=n.getCursor();if(!r.isAtTextEnd())return e.triggerChangeEvent(this);t.preventDefault(),t.stopPropagation(),e.notify("merge",this,"after",r)})).on("enter",(function(t){t.preventDefault(),t.stopPropagation();var n=e.selectionWatcher.getFreshRange().forceCursor();n.isAtTextEnd()?e.notify("insert",this,"after",n):n.isAtBeginning()?e.notify("insert",this,"before",n):e.notify("split",this,n.before(),n.after(),n)})).on("shiftEnter",(function(t){t.preventDefault(),t.stopPropagation();var n=e.selectionWatcher.forceCursor();e.notify("newline",this,n)})).on("bold",(function(t){t.preventDefault(),t.stopPropagation();var n=e.selectionWatcher.getFreshSelection();n.isSelection&&e.notify("toggleBold",n)})).on("italic",(function(t){t.preventDefault(),t.stopPropagation();var n=e.selectionWatcher.getFreshSelection();n.isSelection&&e.notify("toggleEmphasis",n)})).on("character",(function(t){e.notify("change",this)}))}},{key:"setupSelectionChangeListeners",value:function(){var e=this,t=!1,n=!1,r=this.selectionWatcher;this.setupDocumentListener("selectionchange",(function(i){var o=e.selectionWatcher.getFreshSelection();o&&o.isSelection&&o.isAtBeginning()&&o.isAtEnd()?e.notify("selectToBoundary",o.host,i,"both"):o&&o.isSelection&&o.isAtBeginning()?e.notify("selectToBoundary",o.host,i,"start"):o&&o.isSelection&&o.isAtEnd()&&e.notify("selectToBoundary",o.host,i,"end"),n?t=!0:r.selectionChanged()})),this.setupDocumentListener("mousedown",(function(e){this.getEditableBlockByEvent(e)&&(!1===this.config.mouseMoveSelectionChanges&&(n=!0,setTimeout((function(){return r.selectionChanged()}),0)),this.document.addEventListener("mouseup",(function(){n=!1,t&&(t=!1,r.selectionChanged())}),{capture:!0,once:!0}))}))}},{key:"setupSelectionChangeFallbackListeners",value:function(){var e=this;this.setupDocumentListener("mouseup",(function(){setTimeout((function(){return e.selectionWatcher.selectionChanged()}),0)})),this.setupDocumentListener("keyup",(function(t){e.getEditableBlockByEvent(t)&&e.selectionWatcher.selectionChanged()}))}}]),e}();const gn=function(e,t){return e===t||e!=e&&t!=t},vn=function(e,t){for(var n=e.length;n--;)if(gn(e[n][0],t))return n;return-1};var pn=Array.prototype.splice;function yn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}yn.prototype.clear=function(){this.__data__=[],this.size=0},yn.prototype.delete=function(e){var t=this.__data__,n=vn(t,e);return!(n<0||(n==t.length-1?t.pop():pn.call(t,n,1),--this.size,0))},yn.prototype.get=function(e){var t=this.__data__,n=vn(t,e);return n<0?void 0:t[n][1]},yn.prototype.has=function(e){return vn(this.__data__,e)>-1},yn.prototype.set=function(e,t){var n=this.__data__,r=vn(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};const mn=yn,bn="object"==typeof global&&global&&global.Object===Object&&global;var kn="object"==typeof self&&self&&self.Object===Object&&self;const Cn=bn||kn||Function("return this")(),wn=Cn.Symbol;var Sn=Object.prototype,An=Sn.hasOwnProperty,En=Sn.toString,Tn=wn?wn.toStringTag:void 0;var xn=Object.prototype.toString;var Nn=wn?wn.toStringTag:void 0;const On=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Nn&&Nn in Object(e)?function(e){var t=An.call(e,Tn),n=e[Tn];try{e[Tn]=void 0;var r=!0}catch(e){}var i=En.call(e);return r&&(t?e[Tn]=n:delete e[Tn]),i}(e):function(e){return xn.call(e)}(e)},_n=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},jn=function(e){if(!_n(e))return!1;var t=On(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},Rn=Cn["__core-js_shared__"];var Bn,Ln=(Bn=/[^.]+$/.exec(Rn&&Rn.keys&&Rn.keys.IE_PROTO||""))?"Symbol(src)_1."+Bn:"";var Mn=Function.prototype.toString;var In=/^\[object .+?Constructor\]$/,Dn=Function.prototype,Fn=Object.prototype,Hn=Dn.toString,Pn=Fn.hasOwnProperty,Vn=RegExp("^"+Hn.call(Pn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const Wn=function(e){return!(!_n(e)||(t=e,Ln&&Ln in t))&&(jn(e)?Vn:In).test(function(e){if(null!=e){try{return Mn.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t},qn=function(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Wn(n)?n:void 0},Un=qn(Cn,"Map"),zn=qn(Object,"create");var $n=Object.prototype.hasOwnProperty;var Kn=Object.prototype.hasOwnProperty;function Qn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Qn.prototype.clear=function(){this.__data__=zn?zn(null):{},this.size=0},Qn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Qn.prototype.get=function(e){var t=this.__data__;if(zn){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return $n.call(t,e)?t[e]:void 0},Qn.prototype.has=function(e){var t=this.__data__;return zn?void 0!==t[e]:Kn.call(t,e)},Qn.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=zn&&void 0===t?"__lodash_hash_undefined__":t,this};const Xn=Qn,Gn=function(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map};function Yn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Yn.prototype.clear=function(){this.size=0,this.__data__={hash:new Xn,map:new(Un||mn),string:new Xn}},Yn.prototype.delete=function(e){var t=Gn(this,e).delete(e);return this.size-=t?1:0,t},Yn.prototype.get=function(e){return Gn(this,e).get(e)},Yn.prototype.has=function(e){return Gn(this,e).has(e)},Yn.prototype.set=function(e,t){var n=Gn(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};const Jn=Yn;function Zn(e){var t=this.__data__=new mn(e);this.size=t.size}Zn.prototype.clear=function(){this.__data__=new mn,this.size=0},Zn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Zn.prototype.get=function(e){return this.__data__.get(e)},Zn.prototype.has=function(e){return this.__data__.has(e)},Zn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof mn){var r=n.__data__;if(!Un||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Jn(r)}return n.set(e,t),this.size=n.size,this};const er=Zn,tr=function(){try{var e=qn(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),nr=function(e,t,n){"__proto__"==t&&tr?tr(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},rr=function(e,t,n){(void 0!==n&&!gn(e[t],n)||void 0===n&&!(t in e))&&nr(e,t,n)},ir=function(e,t,n){for(var r=-1,i=Object(e),o=n(e),a=o.length;a--;){var s=o[++r];if(!1===t(i[s],s,i))break}return e};var or="object"==typeof exports&&exports&&!exports.nodeType&&exports,ar=or&&"object"==typeof module&&module&&!module.nodeType&&module,sr=ar&&ar.exports===or?Cn.Buffer:void 0,ur=sr?sr.allocUnsafe:void 0;const cr=Cn.Uint8Array,lr=function(e,t){var n,r,i=t?(n=e.buffer,r=new n.constructor(n.byteLength),new cr(r).set(new cr(n)),r):e.buffer;return new e.constructor(i,e.byteOffset,e.length)};var fr=Object.create;const hr=function(){function e(){}return function(t){if(!_n(t))return{};if(fr)return fr(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}(),dr=(gr=Object.getPrototypeOf,vr=Object,function(e){return gr(vr(e))});var gr,vr,pr=Object.prototype;const yr=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||pr)},mr=function(e){return null!=e&&"object"==typeof e},br=function(e){return mr(e)&&"[object Arguments]"==On(e)};var kr=Object.prototype,Cr=kr.hasOwnProperty,wr=kr.propertyIsEnumerable;const Sr=br(function(){return arguments}())?br:function(e){return mr(e)&&Cr.call(e,"callee")&&!wr.call(e,"callee")},Ar=Array.isArray,Er=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},Tr=function(e){return null!=e&&Er(e.length)&&!jn(e)};var xr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Nr=xr&&"object"==typeof module&&module&&!module.nodeType&&module,Or=Nr&&Nr.exports===xr?Cn.Buffer:void 0;const _r=(Or?Or.isBuffer:void 0)||function(){return!1};var jr=Function.prototype,Rr=Object.prototype,Br=jr.toString,Lr=Rr.hasOwnProperty,Mr=Br.call(Object);var Ir={};Ir["[object Float32Array]"]=Ir["[object Float64Array]"]=Ir["[object Int8Array]"]=Ir["[object Int16Array]"]=Ir["[object Int32Array]"]=Ir["[object Uint8Array]"]=Ir["[object Uint8ClampedArray]"]=Ir["[object Uint16Array]"]=Ir["[object Uint32Array]"]=!0,Ir["[object Arguments]"]=Ir["[object Array]"]=Ir["[object ArrayBuffer]"]=Ir["[object Boolean]"]=Ir["[object DataView]"]=Ir["[object Date]"]=Ir["[object Error]"]=Ir["[object Function]"]=Ir["[object Map]"]=Ir["[object Number]"]=Ir["[object Object]"]=Ir["[object RegExp]"]=Ir["[object Set]"]=Ir["[object String]"]=Ir["[object WeakMap]"]=!1;var Dr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Fr=Dr&&"object"==typeof module&&module&&!module.nodeType&&module,Hr=Fr&&Fr.exports===Dr&&bn.process,Pr=function(){try{return Fr&&Fr.require&&Fr.require("util").types||Hr&&Hr.binding&&Hr.binding("util")}catch(e){}}(),Vr=Pr&&Pr.isTypedArray;const Wr=Vr?function(e){return function(t){return e(t)}}(Vr):function(e){return mr(e)&&Er(e.length)&&!!Ir[On(e)]},qr=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};var Ur=Object.prototype.hasOwnProperty;const zr=function(e,t,n){var r=e[t];Ur.call(e,t)&&gn(r,n)&&(void 0!==n||t in e)||nr(e,t,n)};var $r=/^(?:0|[1-9]\d*)$/;const Kr=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&$r.test(e))&&e>-1&&e%1==0&&e<t};var Qr=Object.prototype.hasOwnProperty;const Xr=function(e,t){var n=Ar(e),r=!n&&Sr(e),i=!n&&!r&&_r(e),o=!n&&!r&&!i&&Wr(e),a=n||r||i||o,s=a?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],u=s.length;for(var c in e)!t&&!Qr.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Kr(c,u))||s.push(c);return s};var Gr=Object.prototype.hasOwnProperty;const Yr=function(e){if(!_n(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=yr(e),n=[];for(var r in e)("constructor"!=r||!t&&Gr.call(e,r))&&n.push(r);return n},Jr=function(e){return Tr(e)?Xr(e,!0):Yr(e)},Zr=function(e){return function(e,t,n,r){var i=!n;n||(n={});for(var o=-1,a=t.length;++o<a;){var s=t[o],u=r?r(n[s],e[s],s,n,e):void 0;void 0===u&&(u=e[s]),i?nr(n,s,u):zr(n,s,u)}return n}(e,Jr(e))},ei=function(e,t,n,r,i,o,a){var s,u=qr(e,n),c=qr(t,n),l=a.get(c);if(l)rr(e,n,l);else{var f=o?o(u,c,n+"",e,t,a):void 0,h=void 0===f;if(h){var d=Ar(c),g=!d&&_r(c),v=!d&&!g&&Wr(c);f=c,d||g||v?Ar(u)?f=u:mr(s=u)&&Tr(s)?f=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}(u):g?(h=!1,f=function(e,t){if(t)return e.slice();var n=e.length,r=ur?ur(n):new e.constructor(n);return e.copy(r),r}(c,!0)):v?(h=!1,f=lr(c,!0)):f=[]:function(e){if(!mr(e)||"[object Object]"!=On(e))return!1;var t=dr(e);if(null===t)return!0;var n=Lr.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Br.call(n)==Mr}(c)||Sr(c)?(f=u,Sr(u)?f=Zr(u):_n(u)&&!jn(u)||(f=function(e){return"function"!=typeof e.constructor||yr(e)?{}:hr(dr(e))}(c))):h=!1}h&&(a.set(c,f),i(f,c,r,o,a),a.delete(c)),rr(e,n,f)}},ti=function e(t,n,r,i,o){t!==n&&ir(n,(function(a,s){if(o||(o=new er),_n(a))ei(t,n,s,r,e,i,o);else{var u=i?i(qr(t,s),a,s+"",t,n,o):void 0;void 0===u&&(u=a),rr(t,s,u)}}),Jr)},ni=function(e){return e};var ri=Math.max;const ii=tr?function(e,t){return tr(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:ni;var oi=Date.now;const ai=function(e){var t=0,n=0;return function(){var r=oi(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(ii),si=function(e,t){return ai(function(e,t,n){return t=ri(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=ri(r.length-t,0),a=Array(o);++i<o;)a[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(a),function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(e,this,s)}}(e,t,ni),e+"")},ui=(ci=function(e,t,n){ti(e,t,n)},si((function(e,t){var n=-1,r=t.length,i=r>1?t[r-1]:void 0,o=r>2?t[2]:void 0;for(i=ci.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(e,t,n){if(!_n(n))return!1;var r=typeof t;return!!("number"==r?Tr(n)&&Kr(t,n.length):"string"==r&&t in n)&&gn(n[t],e)}(t[0],t[1],o)&&(i=r<3?void 0:i,r=1),e=Object(e);++n<r;){var a=t[n];a&&ci(e,a,n)}return e})));var ci,li=function(){function e(t){i(this,e),this.spellcheckService=t}return u(e,[{key:"check",value:function(e,t){if(!e)return t(null);var n=ye(e);this.spellcheckService(n,(function(e){e&&e.length>0?t(null,e):t(null)}))}}]),e}(),fi={A0:"no-break space",2e3:"en quad",2001:"em quad",2002:"en space",2003:"em space",2004:"three-per-em space",2005:"four-per-em space",2006:"six-per-em space",2007:"figure space",2008:"punctuation space",2009:"thin space","200A":"hair space","202F":"narrow no-break space","205F":"medium mathematical space",3e3:"ideographic space"},hi=new RegExp("[".concat("\\u2000-\\u200A\\u202F\\u205F\\u3000","]"),"g"),di=function(){function e(t){i(this,e),this.marker=t}return u(e,[{key:"findMatches",value:function(e){var t=this;if(e)return ut(e.matchAll(hi)).map((function(e){return t.prepareMatch(e)}))}},{key:"prepareMatch",value:function(e){var t,n=e.index,r=(t=e[0].charCodeAt(0),"".concat(t.toString(16).toUpperCase())),i=fi[r];return{startIndex:n,endIndex:n+e.length,match:e[0],title:"".concat(i," (\\u").concat(r,")"),marker:this.marker}}}]),e}(),gi=function(){function e(){i(this,e),this.matches=[]}return u(e,[{key:"addMatches",value:function(e){null!=e&&e.length&&(this.matches=function(e,t){for(var n,r=e.length,i=t.length,o=-1,a=[],s={a1:e,i1:0,a2:t,i2:0};s.i1<r||s.i2<i;)(n=vi(s)).startIndex>=o&&a.push(n),o=n.endIndex;return a}(this.matches,e))}}]),e}();function vi(e){var t=e.i1,n=e.i2,r=e.a1[t],i=e.a2[n];return r&&i&&r.startIndex<i.startIndex?(e.i1=t+1,r):r&&i?(e.i2=n+1,i):r?(e.i1=t+1,r):i?(e.i2=n+1,i):void 0}function pi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return yi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yi(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function yi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var mi=function(){function e(t,n,r){i(this,e),this.editable=t,this.win=t.win,this.focusedEditableHost=void 0,this.currentlyCheckedEditableHost=void 0,this.timeout={},this.config=ui({},{checkOnInit:!1,checkOnFocus:!1,checkOnChange:!0,throttle:1e3,removeOnCorrection:!0,spellcheck:{marker:'<span class="highlight-spellcheck"></span>',throttle:1e3,spellcheckService:function(){}},whitespace:{marker:'<span class="highlight-whitespace"></span>'}},n);var o=this.config.spellcheck.spellcheckService,a=this.config.spellcheck.marker,s=this.config.whitespace.marker,u=rn.createMarkerNode(s,"whitespace",this.win);this.spellcheckMarkerNode=rn.createMarkerNode(a,"spellcheck",this.win),this.spellcheckService=new li(o),this.whitespace=new di(u),this.setupListeners()}return u(e,[{key:"setupListeners",value:function(){var e=this;this.config.checkOnFocus&&(this.editable.on("focus",(function(){return e.onFocus.apply(e,arguments)})),this.editable.on("blur",(function(){return e.onBlur.apply(e,arguments)}))),(this.config.checkOnChange||this.config.removeOnCorrection)&&this.editable.on("change",(function(){return e.onChange.apply(e,arguments)})),this.config.checkOnInit&&this.editable.on("init",(function(){return e.onInit.apply(e,arguments)}))}},{key:"onInit",value:function(e){this.highlight(e)}},{key:"onFocus",value:function(e){this.focusedEditableHost!==e&&(this.focusedEditableHost=e,this.editableHasChanged(e))}},{key:"onBlur",value:function(e){this.focusedEditableHost===e&&(this.focusedEditableHost=void 0)}},{key:"onChange",value:function(e){this.config.checkOnChange&&this.editableHasChanged(e,this.config.throttle),this.config.removeOnCorrection&&this.removeHighlightsAtCursor(e)}},{key:"editableHasChanged",value:function(e,t){var n=this;this.timeout.id&&this.timeout.editableHost===e&&clearTimeout(this.timeout.id);var r=setTimeout((function(){n.highlight(e),n.timeout={}}),t||0);this.timeout={id:r,editableHost:e}}},{key:"highlight",value:function(e){var t=this,n=Qt.extractText(e);this.spellcheckService.check(n,(function(n,r){if(!n&&e.isConnected){var i=Qt.extractText(e),o=new gi,a=function(e,t,n){return Xt(e,t,"word",n)}(i,r,t.spellcheckMarkerNode);o.addMatches(a),a=t.whitespace.findMatches(i),o.addMatches(a),t.safeHighlightMatches(e,o.matches)}}))}},{key:"safeHighlightMatches",value:function(e,t){var n=this,r=this.editable.getSelection(e);r?r.retainVisibleSelection((function(){n.highlightMatches(e,t)})):this.highlightMatches(e,t),this.editable.dispatcher&&this.editable.dispatcher.notify("spellcheckUpdated",e)}},{key:"highlightMatches",value:function(e,t){this.removeHighlights(e),t&&t.length>0&&Qt.highlightMatches(e,t)}},{key:"removeHighlights",value:function(e){e=C(e,this.win.document);var t,n=pi(k('[data-highlight="spellcheck"], [data-highlight="whitespace"]',e));try{for(n.s();!(t=n.n()).done;)We(t.value)}catch(e){n.e(e)}finally{n.f()}}},{key:"removeHighlightsAtCursor",value:function(e){e=C(e,this.win.document);var t=this.editable.getSelection(e);if(t&&t.isCursor){var n,r=t.range.startContainer;r.nodeType===y&&(r=r.parentNode);do{if(r===e)return;var i=r.getAttribute("data-highlight");if("spellcheck"===i||"whitespace"===i){n=r.getAttribute("data-word-id");break}}while(r=r.parentNode);n&&t.retainVisibleSelection((function(){var t,r=pi(k('[data-word-id="'.concat(n,'"]'),e));try{for(r.s();!(t=r.n()).done;)We(t.value)}catch(e){r.e(e)}finally{r.f()}}))}}}]),e}();function bi(){if(!1!==c.log&&e.g.console){var t=1===arguments.length?arguments[0]:Array.from(arguments);return 1!==arguments.length&&"trace"===t[t.length-1]&&(t.pop(),console.trace&&console.trace()),console.log(t)}}function ki(e){return ut(new b(e,"getNextTextNode"))}function Ci(e){for(var t,n=e.textNodes,r=e.absOffset,i=0,o=0,a=0;a<n.length;a++){var s=n[a];if(r<=i+s.textContent.length){t=s,o=r-i;break}i+=s.textContent.length}return{node:t,relativeOffset:o}}function wi(e){e.rightLimit=e.currentOffset,e.currentOffset=Math.floor((e.currentOffset+e.leftLimit)/2)}function Si(e){e.leftLimit=e.currentOffset,e.currentOffset=Math.ceil((e.currentOffset+e.rightLimit)/2)}function Ai(e){var t=Ci({textNodes:e.textNodes,absOffset:e.offset}),n=t.node,r=t.relativeOffset,i=n.ownerDocument.createRange();return i.setStart(n,r),i.collapse(!0),i}function Ei(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Ti(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ti(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Ti(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var xi=function(){function e(t){i(this,e);var n,r={window,defaultBehavior:!0,mouseMoveSelectionChanges:!1,browserSpellcheck:!0};this.config=Object.assign(r,t),this.win=this.config.window,this.editableSelector=".".concat(c.editableClass),this.dispatcher=new dn(this),!0===this.config.defaultBehavior&&this.dispatcher.on((n=function(e){var t=e.win.document;return{focus:function(e){H(e)&&e.appendChild(t.createTextNode("\ufeff"))},blur:function(e){t.activeElement!==e&&me(e)},selection:function(e,t){bi(t?"Default selection behavior":"Default selection empty behavior")},cursor:function(e,t){bi(t?"Default cursor behavior":"Default cursor empty behavior")},newline:function(e,n){if(n.isAtTextEnd()){var r,i=t.createElement("br");n.insertBefore(i),(null===(r=i.nextSibling)||void 0===r?void 0:r.nodeType)===y&&"\ufeff"===i.nextSibling.textContent[0]||n.insertAfter(t.createTextNode("\ufeff"))}else n.insertBefore(t.createElement("br"));n.setVisibleSelection()},insert:function(e,t,n){var r=e.parentNode,i=e.cloneNode(!1);switch(i.id&&i.removeAttribute("id"),t){case"before":r.insertBefore(i,e),e.focus();break;case"after":r.insertBefore(i,e.nextSibling),i.focus()}},split:function(e,t,n,r){var i=e.cloneNode(!1);for(i.appendChild(t),e.parentNode.insertBefore(i,e);e.firstChild;)e.removeChild(e.firstChild);e.appendChild(n),ve(i),ve(e),e.focus()},merge:function(t,n,r){var i,o;switch(n){case"before":i=nt(t),o=t;break;case"after":i=t,o=tt(t)}i&&o&&(r=i.childNodes.length>0?e.appendTo(i,o.innerHTML):e.prependTo(i,o.innerHTML),o.remove(),r.save(),ve(i),r.restore(),r.setVisibleSelection())},empty:function(e){bi("Default empty behavior")},switch:function(e,t,n){switch(t){case"before":var r=nt(e);r&&(n.moveAtTextEnd(r),n.setVisibleSelection());break;case"after":var i=tt(e);i&&(n.moveAtBeginning(i),n.setVisibleSelection())}},move:function(e,t,n){bi("Default move behavior")},paste:function(t,n,r){if(0!==n.length){if(r.insertBefore(n.shift()),0===n.length)return r.setVisibleSelection();var i=t.parentNode,o=t;n.forEach((function(e){var n=t.cloneNode(!1);n.id&&n.removeAttribute("id");var r=Ce(e);n.appendChild(r),i.insertBefore(n,o.nextSibling),o=n})),e.createCursorAtEnd(o).setVisibleSelection()}},clipboard:function(e,t,n){bi("Default clipboard behavior")},toggleBold:function(e){e.toggleBold()},toggleEmphasis:function(e){e.toggleEmphasis()}}}(this),{focus:function(e){n.focus(e)},blur:function(e){n.blur(e)},flow:function(e,t){n.flow(e,t)},selection:function(e,t){n.selection(e,t)},cursor:function(e,t){n.cursor(e,t)},newline:function(e,t){n.newline(e,t)},split:function(e,t,r,i){n.split(e,t,r,i)},insert:function(e,t,r){n.insert(e,t,r)},merge:function(e,t,r){n.merge(e,t,r)},empty:function(e){n.empty(e)},switch:function(e,t,r){n.switch(e,t,r)},move:function(e,t,r){n.move(e,t,r)},clipboard:function(e,t,r){n.clipboard(e,t,r)},paste:function(e,t,r){n.paste(e,t,r)},toggleBold:function(e){n.toggleBold(e)},toggleEmphasis:function(e){n.toggleEmphasis(e)}}))}return u(e,[{key:"add",value:function(e,t){return this.enable(e,t),this}},{key:"remove",value:function(e){var t=k(e,this.win.document);this.disable(t);var n,r=Ei(t);try{for(r.s();!(n=r.n()).done;)n.value.classList.remove(c.editableDisabledClass)}catch(e){r.e(e)}finally{r.f()}return this}},{key:"disable",value:function(e){var t,n,r=Ei(k(e||".".concat(c.editableClass),this.win.document));try{for(r.s();!(t=r.n()).done;)(n=t.value).removeAttribute("contenteditable"),n.removeAttribute("spellcheck"),n.removeAttribute("data-plaintext"),function(e,t){if(e.hasAttribute("data-editable")){var n=e.getAttribute("data-editable");et[n]=void 0}}(n),n.classList.remove(c.editableClass),n.classList.add(c.editableDisabledClass)}catch(e){r.e(e)}finally{r.f()}return this}},{key:"enable",value:function(e,t){var n,r=null!=t?t:{},i=r.normalize,o=void 0===i?"boolean"==typeof t&&t:i,a=r.plainText,s=void 0!==a&&a,u=this.config.browserSpellcheck,l=Ei(k(e||".".concat(c.editableDisabledClass),this.win.document));try{for(l.s();!(n=l.n()).done;){var f=n.value;rt(f,{normalize:o,plainText:s,shouldSpellcheck:u}),this.dispatcher.notify("init",f)}}catch(e){l.e(e)}finally{l.f()}return this}},{key:"suspend",value:function(e){var t,n=Ei(k(e||".".concat(c.editableClass),this.win.document));try{for(n.s();!(t=n.n()).done;)t.value.removeAttribute("contenteditable")}catch(e){n.e(e)}finally{n.f()}return this.dispatcher.suspend(),this}},{key:"continue",value:function(e){var t,n=Ei(k(e||".".concat(c.editableClass),this.win.document));try{for(n.s();!(t=n.n()).done;)t.value.setAttribute("contenteditable",!0)}catch(e){n.e(e)}finally{n.f()}return this.dispatcher.continue(),this}},{key:"createCursor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"beginning",n=Wt.findHost(e,this.editableSelector);if(n){var r=A();return"beginning"===t||"end"===t?(r.selectNodeContents(e),r.collapse("beginning"===t)):e!==n?"before"===t?(r.setStartBefore(e),r.setEndBefore(e)):"after"===t&&(r.setStartAfter(e),r.setEndAfter(e)):l("EditableJS: cannot create cursor outside of an editable block."),new Wt(n,r)}}},{key:"createCursorAtCharacterOffset",value:function(e){var t=e.element,n=e.offset,r=Ci({textNodes:ki(t),absOffset:n}),i=r.node,o=r.relativeOffset,a=A();a.setStart(i,o),a.collapse(!0);var s=Wt.findHost(t,this.editableSelector),u=new Wt(s,a);return u.setVisibleSelection(),u}},{key:"createCursorAtBeginning",value:function(e){return this.createCursor(e,"beginning")}},{key:"createCursorAtEnd",value:function(e){return this.createCursor(e,"end")}},{key:"createCursorBefore",value:function(e){return this.createCursor(e,"before")}},{key:"createCursorAfter",value:function(e){return this.createCursor(e,"after")}},{key:"getContent",value:function(e){return be(e)}},{key:"appendTo",value:function(e,t){var n=we(e,this.win.document),r=this.createCursor(n,"end");return r.insertAfter("string"==typeof t?Ce(t):t),r}},{key:"prependTo",value:function(e,t){var n=we(e,this.win.document),r=this.createCursor(n,"beginning");return r.insertBefore("string"==typeof t?Ce(t):t),r}},{key:"getSelection",value:function(e){var t=this.dispatcher.selectionWatcher.getFreshSelection();if(!e||!t)return t;var n=t.range;return null!=e&&e.isConnected&&function(e,t){var n=document.createRange();n.selectNodeContents(e);var r=t.compareBoundaryPoints(Range.START_TO_START,n),i=t.compareBoundaryPoints(Range.END_TO_END,n);return r>=0&&i<=0}(e,n)?t:void 0}},{key:"setupHighlighting",value:function(e){return this.highlighting=new mi(this,e),this}},{key:"setupSpellcheck",value:function(e){var t,n=this;e.markerNode&&(t=e.markerNode.outerHTML),this.setupHighlighting({throttle:e.throttle,spellcheck:{marker:t,spellcheckService:e.spellcheckService}}),this.spellcheck={checkSpelling:function(e){n.highlighting.highlight(e)}}}},{key:"highlight",value:function(e){var t=e.editableHost,n=e.text,r=e.highlightId,i=e.textRange,o=e.raiseEvents,a=e.type,s=void 0===a?"comment":a;return i?"number"!=typeof i.start||"number"!=typeof i.end?(l("Error in Editable.highlight: You passed a textRange object with invalid keys. Expected shape: { start: Number, end: Number }"),-1):i.start===i.end?(l("Error in Editable.highlight: You passed a textRange object with equal start and end offsets, which is considered a cursor and therefore unfit to create a highlight."),-1):rn.highlightRange(t,n,r,i.start,i.end,o?this.dispatcher:void 0,s):rn.highlightText(t,n,r,s)}},{key:"getHighlightPositions",value:function(e){var t=e.editableHost,n=e.type;return rn.extractHighlightedRanges(t,n)}},{key:"removeHighlight",value:function(e){var t=e.editableHost,n=e.highlightId,r=e.raiseEvents;rn.removeHighlight(t,n,r?this.dispatcher:void 0)}},{key:"decorateHighlight",value:function(e){var t=e.editableHost,n=e.highlightId,r=e.addCssClass,i=e.removeCssClass;rn.updateHighlight(t,n,r,i)}},{key:"on",value:function(e,t){return this.dispatcher.on(e,t),this}},{key:"off",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.dispatcher.off.apply(this.dispatcher,t),this}},{key:"unload",value:function(){return this.dispatcher.unload(),this}},{key:"findClosestCursorOffset",value:function(e){var t=e.element,n=e.origCoordinates,r=e.requiredOnFirstLine,i=void 0!==r&&r,o=e.requiredOnLastLine;return function(e){var t=e.host,n=e.requiredOnFirstLine,r=e.requiredOnLastLine,i=e.positionX,o=t.ownerDocument.createRange();o.selectNodeContents(t);var a=o.getBoundingClientRect(),s=ki(t).reduce((function(e,t){return e+t.textContent.length}),0),u=ki(t);if(0===s)return{wasFound:!1};for(var c,l={currentOffset:Math.floor(s/2),leftLimit:0,rightLimit:s},f=l.currentOffset,h=20;l.leftLimit<l.rightLimit&&h>0;){h=h-=1,f=l.currentOffset;var d=Ai({textNodes:u,offset:l.currentOffset}).getBoundingClientRect();c=Math.abs(d.left-i),n&&a.top!==d.top?wi(l):r&&a.bottom!==d.bottom?Si(l):i<d.left?wi(l):Si(l)}var g=Ai({textNodes:u,offset:l.currentOffset}).getBoundingClientRect(),v=Math.abs(g.left-i);return v<c&&(c=v,f=l.currentOffset),{distance:c,offset:f,wasFound:!0}}({host:t,requiredOnFirstLine:i,requiredOnLastLine:void 0!==o&&o,positionX:this.dispatcher.switchContext?this.dispatcher.switchContext.positionX:n.left})}}],[{key:"getGlobalConfig",value:function(){return c}},{key:"globalConfig",value:function(e){Object.assign(c,e),Rt(c)}}]),e}();return xi.parser=n,xi.content=r,["focus","blur","flow","selection","cursor","newline","insert","split","merge","empty","change","switch","move","clipboard","paste","spellcheckUpdated","selectToBoundary"].forEach((function(e){xi.prototype[e]=function(t){return this.on(e,t)}})),t.Editable})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Editable=t():e.Editable=t()}(self,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.d(t,{Editable:()=>xi});var n={};e.r(n),e.d(n,{getHost:()=>D,getNodeIndex:()=>F,isBeginningOfHost:()=>U,isDocumentFragmentWithoutChildren:()=>Z,isEndOfHost:()=>z,isEndOffset:()=>K,isInlineElement:()=>ee,isLinebreak:()=>W,isSameNode:()=>G,isStartOffset:()=>$,isTextEndOfHost:()=>Q,isTextEndOffset:()=>X,isVoid:()=>H,isVoidTextNode:()=>P,isWhitespaceOnly:()=>V,lastChild:()=>Y,lastOffsetWithContent:()=>q,latestChild:()=>J});var r={};function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(e){var t=function(e,t){if("object"!=o(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:String(t)}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}function u(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}e.r(r),e.d(r,{adoptElement:()=>we,areSameAttributes:()=>_e,cleanInternals:()=>me,cloneRangeContents:()=>Se,containsString:()=>Ge,createFragmentFromString:()=>Ce,deleteCharacter:()=>Xe,expandTo:()=>De,extractContent:()=>be,forceWrap:()=>Pe,getAncestorTags:()=>xe,getContainedTags:()=>Re,getInnerHtmlOfFragment:()=>ke,getInnerTags:()=>je,getTagNames:()=>Be,getTags:()=>Te,getTagsByName:()=>Ne,getTagsByNameAndAttributes:()=>Oe,insertCharacter:()=>Ke,isAffectedBy:()=>Le,isExactSelection:()=>Ie,isWrappable:()=>He,normalizeTags:()=>pe,normalizeWhitespace:()=>ye,nuke:()=>ze,nukeElem:()=>$e,nukeTag:()=>Ye,removeFormatting:()=>Ue,removeFormattingElem:()=>qe,selectNodeContents:()=>Me,surround:()=>Qe,tidyHtml:()=>ve,toggleTag:()=>Fe,unwrap:()=>We,unwrapInternalNodes:()=>Ee,wrap:()=>Ve});const c={log:!1,logErrors:!0,editableClass:"js-editable",editableDisabledClass:"js-editable-disabled",pastingAttribute:"data-editable-is-pasting",trimLeadingAndTrailingWhitespaces:!0,boldMarkup:{type:"tag",name:"strong",attribs:{},trim:!0},italicMarkup:{type:"tag",name:"em",attribs:{},trim:!0},underlineMarkup:{type:"tag",name:"u",attribs:{},trim:!1},linkMarkup:{type:"tag",name:"a",attribs:{},trim:!0},pastedHtmlRules:{allowedElements:{a:{href:!0,rel:!0,target:!0},strong:{},em:{},br:{}},allowedPlainTextElements:{br:{}},requiredAttributes:{a:["href"]},transformElements:{b:"strong",i:"em"},splitIntoBlocks:["h1","h2","h3","h4","h5","h6","p","blockquote"],blockLevelElements:["h1","h2","h3","h4","h5","h6","div","p","pre","hr","blockquote","article","figure","header","footer","ul","ol","li","section","table","video"],blacklistedElements:["style","script"],keepInternalRelativeLinks:!1,replaceQuotes:{}}};function l(){if(!1!==c.logErrors){var t=1===arguments.length?arguments[0]:Array.from(arguments);if(e.g.console)return"function"==typeof console.error?console.error(t):void console.log(t)}}var f=Object.prototype.toString,h={"&":"&","<":"<",">":">",'"':""","'":"'"};function d(e){return e.replace(/\s+$/,"")}function g(e){return e.replace(/^\s+|\s+$/g,"")}function v(e){return"[object String]"===f.call(e)}var p=1,y=3,m=11,b=function(e){function t(e,n){i(this,t),this.current=this.previous=this.nextNode=this.root=e,this.iteratorFunc=this[n||"getNext"]}return u(t,[{key:Symbol.iterator,value:function(){return this}},{key:"getNextTextNode",value:function(){for(var e;e=this.getNext();)if(e.nodeType===y&&""!==e.data)return e}},{key:"getPreviousTextNode",value:function(){for(var e;e=this.getPrevious();)if(e.nodeType===y&&""!==e.data)return e}},{key:"next",value:function(){var e=this.iteratorFunc();return e?{value:e}:{done:!0}}},{key:"getNext",value:function(){var e=this.current=this.nextNode,t=this.nextNode=void 0;if(this.current)if((t=e.firstChild)&&"remove"!==e.getAttribute("data-editable"))this.nextNode=t;else for(;e!==this.root&&!(this.nextNode=e.nextSibling);)e=e.parentNode;return this.current}},{key:"getPrevious",value:function(){var e=this.current=this.previous,t=this.previous=void 0;if(this.current)if((t=e.lastChild)&&"remove"!==e.getAttribute("data-editable"))this.previous=t;else for(;e!==this.root&&!(this.previous=e.previousSibling);)e=e.parentNode;return this.current}},{key:"replaceCurrent",value:function(e){this.current=e,this.nextNode=void 0,this.previous=void 0;for(var t=this.current;t!==this.root&&!(this.nextNode=t.nextSibling);)t=t.parentNode}}]),t}(),k=function(e,t){return"string"==typeof e?Array.from(t.querySelectorAll(e)):e.tagName?[e]:Array.isArray(e)?e:Array.from(e)},C=function(e,t){return"string"==typeof e?t.querySelector(e):e.tagName?e:e[0]?e[0]:e},w=function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return t.innerHTML=e,t.firstElementChild},S=function(e,t){if(e.closest||(e=e.parentNode),e&&e.closest)return e.closest(t)},A=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).document.createRange()},E=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).document.getSelection()},T=function(e,t,n){for(var r,i=[],o=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:window).document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ALL,{acceptNode:function(r){return e.intersectsNode(r)&&t.includes(r.nodeType)&&r!==e.commonAncestorContainer?"function"==typeof n?n(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}},!1);r=o.nextNode();)i.push(r);return i},x=function(e){e.startContainer.compareDocumentPosition(e.endContainer)===Node.DOCUMENT_POSITION_FOLLOWING&&e.setStartBefore(e.endContainer),e.endContainer.compareDocumentPosition(e.startContainer)===Node.DOCUMENT_POSITION_PRECEDING&&e.setEndAfter(e.startContainer)},N=function(e,t){var n=document.createRange();n.selectNodeContents(t);var r=e.compareBoundaryPoints(Range.START_TO_START,n),i=e.compareBoundaryPoints(Range.END_TO_END,n);return r<=0&&i>=0},O=function(e){return e&&(e.nodeType===Node.TEXT_NODE||e.nodeType===Node.COMMENT_NODE)},_=function(e,t){return e.splitText(t)},j=function(e){var t=e.startContainer,n=e.startOffset,r=e.endContainer,i=e.endOffset;if(O(r)&&i>0&&i<r.length&&_(r,i),O(t)&&n>0&&n<t.length){var o=_(t,n);e.setStart(o,0)}},R=function(e,t){var n=e.cloneRange();n.setStart(t,0),n.setEnd(e.startContainer,e.startOffset);var r=e.toString(),i=n.toString().length;return{start:i,end:i+r.length,text:r}},B=function(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset};function L(e){var t=e.root,n=e.startContainer,r=e.startOffset,i=e.whitespacesOnTheLeft;if(n.nodeType!==y)return L({root:t,startContainer:n.childNodes[r],startOffset:0,whitespacesOnTheLeft:i});var o=r+i;if(n.length>o)return[n,o];var a=new b(t);a.nextNode=n,a.getNextTextNode();var s=a.getNextTextNode();if(!s){var u=a.getPreviousTextNode();return[u,u.length]}return L({root:t,startContainer:s,startOffset:0,whitespacesOnTheLeft:o-n.length})}function M(e){var t=e.root,n=e.endContainer,r=e.endOffset,i=e.whitespacesOnTheRight;if(n.nodeType!==y){var o=!n.childNodes[r-1],a=o?n.childNodes[r]:n.childNodes[r-1],s=0;return o||(s=a.nodeType===y?a.length:a.childNodes.length),M({root:t,endContainer:a,endOffset:s,whitespacesOnTheRight:i})}var u=r-i;if(u>0)return[n,u];var c=new b(t);c.previous=n,c.getPreviousTextNode();var l=c.getPreviousTextNode();return l?M({root:t,endContainer:l,endOffset:l.length,whitespacesOnTheRight:i-r}):[c.getNextTextNode(),0]}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function D(e){return e=e.jquery?e[0]:e,S(e,".".concat(c.editableClass))}function F(e){for(var t=0;null!==(e=e.previousSibling);)t++;return t}function H(e){var t,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return I(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?I(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(e.childNodes);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r.nodeType===y&&!P(r))return!1;if(r.nodeType===p)return!1}}catch(e){n.e(e)}finally{n.f()}return!0}function P(e){return e.nodeType===y&&!e.nodeValue}function V(e){return e.nodeType===y&&0===q(e)}function W(e){return e.nodeType===p&&"BR"===e.tagName}function q(e){if(e.nodeType===y)return d(e.nodeValue).length;var t=0;return Array.from(e.childNodes).reverse().every((function(e,n,r){return!(!V(e)&&!W(e)&&(t=r.length-n,1))})),t}function U(e,t,n){if(t===e)return $(t,n);if($(t,n)){var r=F(t);return U(e,t.parentNode,r)}return!1}function z(e,t,n){if(t===e)return K(t,n);if(K(t,n)){var r=F(t)+1;return z(e,t.parentNode,r)}return!1}function $(e,t){return e.nodeType===y?0===t:0===e.childNodes.length||1===e.childNodes.length&&e.firstChild.nodeType===p&&"remove"===e.firstChild.getAttribute("data-editable")||e.childNodes[t]===e.firstChild}function K(e,t){return e.nodeType===y?t===e.length:0===e.childNodes.length||t>0&&e.childNodes[t-1]===e.lastChild}function Q(e,t,n){if(t===e)return X(t,n);if(X(t,n)){var r=F(t)+1;return Q(e,t.parentNode,r)}return!1}function X(e,t){return e.nodeType===y?t>=d(e.nodeValue).length:0===e.childNodes.length||t>=q(e)}function G(e,t){var n,r,i;if(e.nodeType!==t.nodeType)return!1;if(e.nodeName!==t.nodeName)return!1;for(n=0,r=e.attributes.length;n<r;n++)if(i=e.attributes[n],t.getAttribute(i.name)!==i.value)return!1;return!0}function Y(e){return e.lastChild?Y(e.lastChild):e}function J(e){return console.warn("Editable.js: Using obsolete function parser.latestCild(), use lastChild() instead"),Y(e)}function Z(e){return e&&e.nodeType===m&&0===e.childNodes.length}function ee(e,t){switch((t.currentStyle||e.getComputedStyle(t,"")).display){case"inline":case"inline-block":return!0;default:return!1}}var te=0,ne="\ufeff";function re(e,t){var n=e.commonAncestorContainer;if(3===n.nodeType)return!1;var r=t.parentElement;return(null==r?void 0:r.parentElement)===n}function ie(e,t){var n=e.commonAncestorContainer;n.ownerDocument||l("Cannot save range: range is empty");var r=n.ownerDocument.defaultView.document,i=r.createElement("span");i.id="editable-range-boundary-".concat(++te),i.setAttribute("data-editable","remove"),i.style.lineHeight="0",i.style.display="none",i.appendChild(r.createTextNode(ne));var o=t&&re(e,e.startContainer),a=!t&&re(e,e.endContainer);if(o){var s=e.startContainer.parentElement;s.parentElement.insertBefore(i,s)}else if(a){var u=e.endContainer.parentElement;u.parentElement.insertBefore(i,u.nextSibling)}else{var c=e.cloneRange();c.collapse(t),c.insertNode(i)}return i}function oe(e,t,n,r){var i=ue(e,n);if(!i)return console.log("Marker element has been removed. Cannot restore selection.");t[r?"setStartBefore":"setEndBefore"](i),i.remove()}function ae(e){var t,n,r;return e.collapsed?t={markerId:(r=ie(e,!1)).id,collapsed:!0}:(r=ie(e,!1),t={startMarkerId:(n=ie(e,!0)).id,endMarkerId:r.id,collapsed:!1}),e.collapsed?(e.setStartBefore(r),e.collapse(!0)):(e.setEndBefore(r),e.setStartAfter(n)),t}function se(e,t){if(!t.restored){var n=A();if(t.collapsed){var r=ue(e,t.markerId);if(r){r.style.display="inline";var i=r.previousSibling;i&&i.nodeType===y?(r.remove(),n.setStart(i,i.length)):(n.setStartBefore(r),n.collapse(!0),r.remove())}else console.log("Marker element has been removed. Cannot restore selection.")}else oe(e,n,t.startMarkerId,!0),oe(e,n,t.endMarkerId,!1);return x(n),n}}function ue(e,t){return e.querySelector("#".concat(t))}function ce(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return le(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?le(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function le(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function fe(e,t,n){return t=ae(t),n(),se(e,t)}var he=/\u200B/g,de=/\uFEFF/g,ge=/[^\S ]/g;function ve(e){pe(e)}function pe(e){var t=document.createDocumentFragment();Ae(e,"firstChild"),Ae(e,"lastChild");var n,r=ce(e.childNodes);try{for(r.s();!(n=r.n()).done;){var i=n.value;if("BR"===i.nodeName||i.textContent){if(i.nodeType===p&&"BR"!==i.nodeName){for(var o=i;null!==(o=o.nextSibling)&&G(o,i);){var a,s=ce(o.childNodes);try{for(s.s();!(a=s.n()).done;){var u=a.value;i.appendChild(u.cloneNode(!0))}}catch(e){s.e(e)}finally{s.f()}o.remove()}pe(i)}t.appendChild(i.cloneNode(!0))}}}catch(e){r.e(e)}finally{r.f()}for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(t)}function ye(e){return e.replace(ge," ")}function me(e){e.innerHTML=be(e,!0)}function be(e,t){var n=(e.nodeType===m?ke(e):e.innerHTML).replace(de,"").replace(he,"<br>"),r=document.createElement("div");return r.innerHTML=n,Ee(r,t),Ae(r,"firstChild"),Ae(r,"lastChild"),r.innerHTML}function ke(e){var t=document.createElement("div");return t.appendChild(e),t.innerHTML}function Ce(e){var t=document.createElement("div");t.innerHTML=e;for(var n=document.createDocumentFragment();t.firstChild;)n.appendChild(t.firstChild);return n}function we(e,t){return e.ownerDocument!==t?t.adoptNode(e):e}function Se(e){for(var t=e.cloneContents().childNodes[0],n=document.createDocumentFragment();t.childNodes.length;)n.appendChild(t.childNodes[0]);return n}function Ae(e,t){for(var n,r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];r=e[t];)if(r.nodeType===y){if(!/^\s+$/.test(r.textContent))break;e.removeChild(r)}else{if("BR"!==r.nodeName){r[t]&&Ae(r,t,!1);break}r.remove()}i&&(null===(n=r=e[t])||void 0===n?void 0:n.nodeType)===y&&c.trimLeadingAndTrailingWhitespaces&&(r.textContent=r.textContent.replace(t.startsWith("last")?/ +$/:/^ +/,""))}function Ee(e,t){for(;e;){var n=e.nextSibling;if(e.nodeType===p){var r=e.getAttribute("data-editable");e.firstChild&&Ee(e.firstChild,t),("remove"===r||"ui-remove"===r&&!t)&&e.remove(),("unwrap"===r||"ui-unwrap"===r&&!t)&&We(e),e=n}else e=n}}function Te(e,t,n){var r=je(t,n),i=xe(e,t,n);return r.concat(i)}function xe(e,t,n){for(var r=[],i=t.commonAncestorContainer;i!==e;)n&&!n(i)||r.push(i),i=i.parentNode;return r}function Ne(e,t,n){return Te(e,t,(function(e){return e.nodeName.toUpperCase()===n.toUpperCase()}))}function Oe(e,t,n){return Te(e,t,(function(e){return e.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&_e(e.attributes,n.attributes)}))}function _e(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=t[e[n].name];if(!r||r.value!==e[n].value)return!1}return!0}function je(e,t){return T(e,[p],t)}function Re(e,t){return T(e,[p],t).filter((function(t){return N(e,t)}))}function Be(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((function(e){return e.nodeName}))}function Le(e,t,n){return Te(e,t).some((function(e){return e.nodeName===n.toUpperCase()}))}function Me(e){var t=A();return t.selectNodeContents(e),t}function Ie(e,t,n){var r,i,o=A();if(o.selectNodeContents(t),i=o,-1!==(r=e).compareBoundaryPoints(Range.END_TO_START,i)||-1!==i.compareBoundaryPoints(Range.END_TO_START,r))return!1;var a=e.toString(),s=(t.jquery?t[0]:t).textContent;return n&&(a=g(a),s=g(s)),""!==a&&a===s}function De(e,t,n){return t.selectNodeContents(n),t}function Fe(e,t,n){var r=Oe(e,t,n);return 1===r.length&&Ie(t,r[0],"visible")?qe(e,t,n):Pe(e,t,n)}function He(e){return function(e){if(!e||!e.startContainer||!e.endContainer)return!1;if(e.startContainer===e.endContainer)return!0;for(var t,n=function(e,t){var n=e,r=null;return{next:function(){if(!n)return null;if(n.firstChild&&r!==n.firstChild)r=n,n=n.firstChild;else if(n.nextSibling)r=n,n=n.nextSibling;else{for(var t=n.parentNode;t&&t!==e;){if(t.nextSibling){r=n=t.nextSibling;break}t=t.parentNode}t&&t!==e||(r=n=null)}return n}}}(e.commonAncestorContainer),r=!1;t=n.next();)if(t.nodeType===Node.ELEMENT_NODE&&!Je(t,e)){r=!0;break}return!r}(e)}function Pe(e,t,n){var r=fe(e,t,(function(){$e(e,t,n)}));return He(r)||(r=fe(e,r,(function(){ze(e,r)}))),Ve(r,n),r}function Ve(e,t){He(e)?("string"==typeof t&&(t=w(t)),e.surroundContents(t)):console.log("content.wrap(): can not surround range")}function We(e){for(var t=(e=e.jquery?e[0]:e).parentNode;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}function qe(e,t,n){return fe(e,t,(function(){$e(e,t,n)}))}function Ue(e,t,n){return fe(e,t,(function(){ze(e,t,n)}))}function ze(e,t,n){Te(e,t).forEach((function(e){"BR"===e.nodeName.toUpperCase()||n&&!e.matches(n)||We(e)}))}function $e(e,t,n){Te(e,t).forEach((function(e){"BR"!==e.nodeName.toUpperCase()&&(!n||e.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&_e(e.attributes,n.attributes))&&We(e)}))}function Ke(e,t,n){var r=document.createTextNode(t),i=e.cloneRange();i.collapse(n),i.insertNode(r),e[n?"setStartBefore":"setEndAfter"](r),x(e)}function Qe(e,t,n,r){return Ke(t,r||n,!1),Ke(t,n,!0),t}function Xe(e,t,n){if(!Ge(t,n))return t;window.getSelection().rangeCount>0&&j(t);var r=fe(e,t,(function(){T(t,[y],(function(e){return e.nodeValue.indexOf(n)>=0})).forEach((function(e){e.nodeValue=e.nodeValue.replaceAll(n,"")}))}));return x(r),r}function Ge(e,t){return e.toString().indexOf(t)>=0}function Ye(e,t,n){Te(e,t).forEach((function(e){e.nodeName.toUpperCase()===n.toUpperCase()&&We(e)}))}function Je(e,t){var n=document.createRange();return n.selectNodeContents(e),t.compareBoundaryPoints(Range.START_TO_START,n)<=0&&t.compareBoundaryPoints(Range.END_TO_END,n)>=0}var Ze=1,et={},tt=ot("nextElementSibling"),nt=ot("previousElementSibling");function rt(e,t){var n=t.normalize,r=t.plainText,i=t.shouldSpellcheck;!function(e){e.hasAttribute("data-editable")||(e.setAttribute("data-editable","id-".concat(Ze)),Ze+=1)}(e),e.setAttribute("contenteditable",!0),e.setAttribute("spellcheck",Boolean(i)),e.setAttribute("data-plaintext",Boolean(r)),e.classList.remove(c.editableDisabledClass),e.classList.add(c.editableClass),n&&ve(e)}function it(e){return"true"===e.getAttribute("data-plaintext")}function ot(e){return function(t){var n=t[e];return n&&n.getAttribute("contenteditable")?n:null}}function at(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function st(e,t){if(e){if("string"==typeof e)return at(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?at(e,t):void 0}}function ut(e){return function(e){if(Array.isArray(e))return at(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||st(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var ct,lt,ft,ht,dt,gt,vt,pt,yt,mt=[["«","»"],["»","«"],['"','"'],["“","”"],["”","”"],["“","“"],["„","“"]],bt=[["‘","’"],["‹","›"],["‚","‘"],["’","’"],["›","‹"],["'","'"],["‘","’"]],kt=["’","'"],Ct=/([‘’‹›‚'«»"“”„])(?![^<]*?>)/g,wt=/\s|[>\-–—«»”"“„]/,St=/\s|[<\-–—«»”"“‘’‹›'.;?:,]/;function At(e,t){(ct=t||{}).quotes=ct.quotes||[void 0,void 0],ct.singleQuotes=ct.singleQuotes||[void 0,void 0];var n=function(e){return ut(e.matchAll(Ct)).map((function(t){var n=t.index;return{char:t[1],before:n>0?e[n-1]:"",after:n+1<e.length?e[n+1]:""}}))}(e);return n.length>0?(Et(n,0),function(e,t){var n=0;return e.replace(Ct,(function(e){var r=t[n].replace||t[n].char;return n+=1,r}))}(e,n)):e}function Et(e,t){for(;t<e.length;){var n=Tt(e,t);if(n){if(e[t].replace="double"===n.type?ct.quotes[0]:ct.singleQuotes[0],e[n.position].replace="double"===n.type?ct.quotes[1]:ct.singleQuotes[1],n.position!==t+1){var r=e.slice(t+1,n.position);r&&Et(r,0)}t=n.position+1}else e[t].replace=Nt(e[t].char),t+=1}}function Tt(e,t){if(t!==e.length-1){var n=e[t],r=n.char;if(!n.before||wt.test(n.before))for(var i=xt(r,bt),o=xt(r,mt),a=t+1;a<e.length;a++)if(e[a].after&&St.test(e[a].after)||!e[a].after){if(i.includes(e[a].char))return{position:a,type:"single"};if(o.includes(e[a].char))return{position:a,type:"double"}}}}function xt(e,t){return t.filter((function(t){return t[0]===e})).map((function(e){return e[1]}))}function Nt(e){if(kt.includes(e))return ct.apostrophe}var Ot,_t=/^\s*$/,jt="\x3c!-- BLOCK --\x3e";function Rt(e){var t=e.pastedHtmlRules;lt=t.allowedElements||{},ft=t.allowedPlainTextElements||{},ht=t.requiredAttributes||{},dt=t.transformElements||{},yt=t.blacklistedElements||[],Ot=t.keepInternalRelativeLinks||!1,vt=t.replaceQuotes||{},gt={},t.blockLevelElements.forEach((function(e){gt[e]=!0})),pt={},t.splitIntoBlocks.forEach((function(e){pt[e]=!0}))}function Bt(e,t,n){var r=e.ownerDocument;e.setAttribute(c.pastingAttribute,!0),t.isSelection&&(t=t.deleteExactSurroundingTags().deleteContainedTags().deleteContent());var i=r.createElement("div");i.innerHTML=n;var o=function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).plainText,n=void 0!==t&&t;return Lt(e,{allowedElements:n?ft:lt,keepInternalRelativeLinks:!n&&Ot}).split(jt).map((function(e){return g((t=e,vt.quotes||vt.singleQuotes||vt.apostrophe?At(t,vt):t).replace(/\n/g," ").replace(/ {2,}/g," ").replace(/(.)\u00A0/g,(function(e,t){return t+(/[\u0020]/.test(t)?" ":" ")})));var t})).filter((function(e){return!_t.test(e)}))}(i,{plainText:it(e)});return e.removeAttribute(c.pastingAttribute),{blocks:o,cursor:t}}function Lt(e,t){return Array.from(e.childNodes).reduce((function(e,n){if(-1!==yt.indexOf(n.nodeName.toLowerCase()))return"";if(t.keepInternalRelativeLinks&&"A"===n.nodeName&&n.href){var r=n.getAttribute("href").replace(window.location.origin,"");n.setAttribute("href",r)}return n.nodeType===p?e+function(e,t,n){var r=e.nodeName.toLowerCase();if(function(e,t,n){return n.allowedElements[e]&&function(e,t){var n=ht[e];return!n||!n.some((function(e){return!t.getAttribute(e)}))}(e,t)}(r=function(e){return dt[e]||e}(r),e,n)){var i=function(e,t){return Array.from(t.attributes).reduce((function(t,n){var r=n.name,i=n.value;return lt[e][r]&&i?"".concat(t," ").concat(r,'="').concat(i,'"'):t}),"")}(r,e);return"br"===r?"<".concat(r+i,">"):_t.test(t)?t:"<".concat(r+i,">").concat(t,"</").concat(r,">")}return pt[r]?jt+t+jt:gt[r]?"".concat(t," "):t}(n,Lt(n,t),t):n.nodeType===y?e+n.nodeValue.replace(/[&<>]/g,(function(e){return h[e]})):e}),"")}Rt(c),document.documentElement.contentEditable;var Mt=/(apple)?webkit\/537\.36/i.test(window.navigator.userAgent),It=/(apple)?webkit/i.test(window.navigator.userAgent),Dt=!Mt&&It,Ft=function(e){var t=e,n=t.onselectionchange;if(void 0!==n)try{return t.onselectionchange=0,null===t.onselectionchange}catch(e){}finally{t.onselectionchange=n}return!1}(document),Ht=!!Dt;function Pt(e,t){var n=function(e){var t={};function n(e,n){e.split(" ").forEach((function(e){t[e]=t[e]||[],t[e].unshift(n)}))}return{on:function(e,t){if(2===arguments.length)n(e,t);else if(1===arguments.length)for(var r in e)n(r,e[r]);return this},off:function(e,n){2===arguments.length?function(e,n){var r=t[e];if(r){var i=r.indexOf(n);i<0||r.splice(i,1)}}(e,n):1===arguments.length?t[e]=[]:t={}},notify:function(n,r){var i=Array.from(arguments);e?(r=n,n=e,i.splice(0,1)):i.splice(0,2),this.switchContext&&r!==this.switchContext.events.shift()&&(this.switchContext=void 0);var o=t[r];o&&o.every((function(e){return!1!==e.apply(n,i)}))}}}(t);e.on=n.on,e.off=n.off,e.notify=n.notify}function Vt(e){return{x:void 0!==e.pageXOffset?e.pageXOffset:(e.document.documentElement||e.document.body.parentNode||e.document.body).scrollLeft,y:void 0!==e.pageYOffset?e.pageYOffset:(e.document.documentElement||e.document.body.parentNode||e.document.body).scrollTop}}var Wt=function(){function e(t,n){i(this,e),this.setHost(t),this.range=n,this.isCursor=!0}return u(e,[{key:"getTags",value:function(e){return Te(this.host,this.range,e)}},{key:"getTagNames",value:function(e){return Be(this.getTags(e))}},{key:"getTagsByName",value:function(e){return Ne(this.host,this.range,e)}},{key:"getInnerTags",value:function(e){return je(this.range,e)}},{key:"getContainedTags",value:function(e){return Re(this.range,e)}},{key:"getAncestorTags",value:function(e){return xe(this.host,this.range,e)}},{key:"isAtEnd",value:function(){return z(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtTextEnd",value:function(){return Q(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtLastLine",value:function(){var e=this.win.document.createRange();e.selectNodeContents(this.host),e.collapse(!1);var t=qt(e,this.win),n=qt(this.range,this.win);return Ut(t.bottom,n.bottom)}},{key:"isAtFirstLine",value:function(){var e=this.win.document.createRange();e.selectNodeContents(this.host),e.collapse(!0);var t=qt(e,this.win),n=qt(this.range,this.win);return Ut(t.top,n.top)}},{key:"isAtBeginning",value:function(){return U(this.host,this.range.startContainer,this.range.startOffset)}},{key:"insertBefore",value:function(e){if(v(e)&&(e=Ce(e)),!Z(e)){var t=e=this.adoptElement(e);if(e.nodeType===m){var n=e.childNodes.length-1;t=e.childNodes[n]}this.range.insertNode(e),this.range.setStartAfter(t),this.range.setEndAfter(t),this.host.normalize()}}},{key:"insertAfter",value:function(e){if(v(e)&&(e=Ce(e)),!Z(e)){e=this.adoptElement(e);var t=this.range.cloneRange();t.setStart(t.endContainer,t.endOffset),t.collapse(!0),t.insertNode(e),this.host.normalize()}}},{key:"setSelection",value:function(){this.setVisibleSelection()}},{key:"setVisibleSelection",value:function(){if(this.win.document.activeElement!==this.host){var e=Vt(this.win),t=e.x,n=e.y;this.win.scrollTo(t,n)}var r=E(this.win);r.removeAllRanges(),r.addRange(this.range)}},{key:"before",value:function(){var e=this.range.cloneRange();return e.collapse(!0),e.setStartBefore(this.host),Se(e)}},{key:"textBefore",value:function(){var e=this.range.cloneRange();return e.collapse(!0),e.setStartBefore(this.host),e.toString()}},{key:"beforeHtml",value:function(){return ke(this.before())}},{key:"after",value:function(){var e=this.range.cloneRange();return e.collapse(!1),e.setEndAfter(this.host),Se(e)}},{key:"textAfter",value:function(){var e=this.range.cloneRange();return e.collapse(!1),e.setEndAfter(this.host),e.toString()}},{key:"afterHtml",value:function(){return ke(this.after())}},{key:"getBoundingClientRect",value:function(){return this.range.getBoundingClientRect()}},{key:"getCoordinates",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"absolute",t=this.range.getBoundingClientRect();if("fixed"===e)return t;var n=Vt(this.win),r=n.x,i=n.y;return{top:t.top+i,bottom:t.bottom+i,left:t.left+r,right:t.right+r,height:t.height,width:t.width}}},{key:"moveBefore",value:function(t){if(this.updateHost(t),this.range.setStartBefore(t),this.range.setEndBefore(t),this.isSelection)return new e(this.host,this.range)}},{key:"moveAfter",value:function(t){if(this.updateHost(t),this.range.setStartAfter(t),this.range.setEndAfter(t),this.isSelection)return new e(this.host,this.range)}},{key:"moveAtBeginning",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(t),this.range.selectNodeContents(t),this.range.collapse(!0),this.isSelection)return new e(this.host,this.range)}},{key:"moveAtEnd",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(t),this.range.selectNodeContents(t),this.range.collapse(!1),this.isSelection)return new e(this.host,this.range)}},{key:"moveAtTextEnd",value:function(e){return this.moveAtEnd(Y(e))}},{key:"setHost",value:function(e){e.jquery&&(e=e[0]),this.host=e,this.win=null==e?window:e.ownerDocument.defaultView}},{key:"updateHost",value:function(e){var t=D(e);t||l("Can not set cursor outside of an editable block"),this.setHost(t)}},{key:"retainVisibleSelection",value:function(e){this.save(),e(),this.restore(),this.setVisibleSelection()}},{key:"save",value:function(){this.savedRangeInfo=ae(this.range),this.savedRangeInfo.host=this.host}},{key:"restore",value:function(){this.savedRangeInfo||l("Could not restore selection"),this.host=this.savedRangeInfo.host,this.range=se(this.host,this.savedRangeInfo),this.savedRangeInfo=void 0}},{key:"equals",value:function(e){return!!(e&&e.host&&e.host.isEqualNode(this.host)&&e.range&&B(e.range,this.range))}},{key:"createElement",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.win.document.createElement(e);for(var r in t){var i=t[r];n.setAttribute(r,i)}return n}},{key:"createTextNode",value:function(e){return this.win.document.createTextNode(e)}},{key:"adoptElement",value:function(e){return we(e,this.win.document)}},{key:"triggerChange",value:function(){var e=new Event("formatEditable",{bubbles:!0,cancelable:!1});this.host.dispatchEvent(e)}}],[{key:"findHost",value:function(e,t){return S(e,t)}}]),e}();function qt(e,t){if(e.startContainer.nodeType!==p)return e.getBoundingClientRect();var n=t.document.createElement("span");n.setAttribute("doc-editable","unwrap"),e.insertNode(n);var r=n.getBoundingClientRect();return n.remove(),r}function Ut(e,t){return e===t||Math.abs(e-t)<=2}function zt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,t)||st(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $t(e){return $t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},$t(e)}function Kt(e,t){return Kt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Kt(e,t)}const Qt={extractText:function(e){var t="";return function(e,t,n){for(var r,i=new b(e);r=i.getNext();)r.nodeType===y&&""!==r.data?n(r.data):t&&r.nodeType===p&&"BR"===r.nodeName&&n("\n")}(e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],(function(e){t+=e})),t},highlightMatches:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(t&&0!==t.length){e.normalize();for(var r,i,o,a=new b(e),s=0,u=0,c=t[s],l=[];r=a.getNext();)if(r.nodeType===y&&""!==r.data){var f=(o=r).data,h=u+f.length;if(c.startIndex<h&&u<c.endIndex){var d=u<=c.startIndex,g=h>=c.endIndex;d&&(i=c.id||c.startIndex);var v;v=d?c.startIndex-u:0;var m;m=g?c.endIndex-u-v:f.length-v;var k={element:o,text:f.substring(v,v+m),offset:v,length:m,isLastPortion:g,wordId:i};if(l.push(k),g){var C=this.wrapMatch(l,c.marker,c.title);a.replaceCurrent(C),h=u+k.length+k.offset,l=[],(s+=1)<t.length&&(c=t[s])}}u=h}else if(n&&r.nodeType===p&&"BR"===r.nodeName){u+=1;continue}}},wrapMatch:function(e,t,n){var r=this;return e.map((function(e){return r.wrapPortion(e,t,n)})).pop()},wrapPortion:function(e,t,n){var r=A();r.setStart(e.element,e.offset),r.setEnd(e.element,e.offset+e.length);var i=t.cloneNode(!0);if(i.setAttribute("data-word-id",e.wordId),n&&i.setAttribute("title",n),r.surroundContents(i),i.nextSibling){var o=i.nextSibling;o.nodeType===y&&""===o.data&&o.remove()}return i}};function Xt(e,t,n,r){if(!e||""===e)return[];if(r&&!function(e){try{var t;return!!e&&e instanceof(null===(t=e.ownerDocument)||void 0===t?void 0:t.defaultView.HTMLElement)}catch(t){return"object"===o(e)&&1===e.nodeType&&"object"===o(e.style)&&"object"===o(e.ownerDocument)}}(r))return[];if(null==t||!t.length)return[];var i=("word"===n?Jt:Gt)(t);return ut(e.matchAll(i)).map((function(e){var t,i;return"word"===n?(t=e.index+e[1].length,i=e[2]):(t=e.index,i=e[0]),{startIndex:t,endIndex:t+i.length,match:i,marker:r}}))}function Gt(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((function(e){return Zt(e)})),t="(".concat(e.join("|"),")");return new RegExp(t,"g")}var Yt="\\u0041-\\u005A\\u0061-\\u007A\\u0030-\\u0039\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u00FF\\u0100-\\u017F\\u0180-\\u024F";function Jt(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map((function(e){return Zt(e)})),t="([^".concat(Yt,"]|^)")+"(".concat(e.join("|"),")")+"(?=[^".concat(Yt,"]|$)");return new RegExp(t,"g")}function Zt(e){return String(e).replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function en(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return tn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?tn(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function tn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var nn={highlightText:function(e,t,n,r){if(!this.hasHighlight(e,n)){var i=Qt.extractText(e),o='<span class="highlight-'.concat(r,'"></span>'),a=function(e,t,n){return Xt(e,[t],"text",n)}(i,t,nn.createMarkerNode(o,r,this.win));return a&&a.length?(n&&(a[0].id=n),Qt.highlightMatches(e,a),a[0].startIndex):void 0}},highlightRange:function(e,t,n,r,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"comment";if(this.hasHighlight(e,n)&&this.removeHighlight(e,n),""===Qt.extractText(e,!1))return-1;var s=nn.createMarkerNode('<span class="highlight-'.concat(a,'"></span>'),a,this.win),u=r,c=i;return Qt.highlightMatches(e,[{startIndex:u,endIndex:c,id:n,marker:s}],!1),o&&o.notify("change",e),u},updateHighlight:function(e,t,n,r){if(document.documentElement.classList){var i,o=en(e.querySelectorAll('[data-word-id="'.concat(t,'"]')));try{for(o.s();!(i=o.n()).done;){var a=i.value;r&&a.classList.remove(r),n&&a.classList.add(n)}}catch(e){o.e(e)}finally{o.f()}}},removeHighlight:function(e,t,n){var r,i=en(e.querySelectorAll('[data-word-id="'.concat(t,'"]')));try{for(i.s();!(r=i.n()).done;)We(r.value)}catch(e){i.e(e)}finally{i.f()}e.normalize(),n&&n.notify("change",e)},hasHighlight:function(e,t){return!!e.querySelectorAll('[data-word-id="'.concat(t,'"]')).length},extractHighlightedRanges:function(e,t){var n="[data-word-id]";t&&(n+='[data-highlight="'.concat(t,'"]'));var r=e.querySelectorAll(n);if(r.length){var i,o={},a=en(r);try{for(a.s();!(i=a.n()).done;){var s=i.value.getAttribute("data-word-id");o[s]||(o[s]=e.querySelectorAll('[data-word-id="'.concat(s,'"]')))}}catch(e){a.e(e)}finally{a.f()}var u={};for(var c in o){var l=this.extractMarkerNodePosition(e,o[c]);l&&(u[c]=l)}return u}},extractMarkerNodePosition:function(e,t){var n=A();t.length>1?(n.setStartBefore(t[0]),n.setEndAfter(t[t.length-1])):n.selectNode(t[0]);var r=R(n,e);return{start:r.start,end:r.end,text:r.text,nativeRange:n}},cleanupStaleMarkerNodes:function(e,t){var n,r=en(e.querySelectorAll('span[data-highlight="'.concat(t,'"]')));try{for(r.s();!(n=r.n()).done;){var i=n.value;i.textContent.length||i.remove()}}catch(e){r.e(e)}finally{r.f()}},createMarkerNode:function(e,t,n){var r=w(e,n);return r.setAttribute("data-editable","ui-unwrap"),r.setAttribute("data-highlight",t),r}};const rn=nn;function on(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var an=function(e){function t(){var e;return i(this,t),delete(e=function(e,t,n){return t=$t(t),function(e,t){if(t&&("object"===o(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){return!1}}()?Reflect.construct(t,n||[],$t(e).constructor):t.apply(e,n))}(this,t,arguments)).isCursor,e.isSelection=!0,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Kt(e,t)}(t,e),u(t,[{key:"text",value:function(){return this.range.toString()}},{key:"html",value:function(){return function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return t.appendChild(e.cloneContents()),t.innerHTML}(this.range)}},{key:"isAllSelected",value:function(){return U(this.host,this.range.startContainer,this.range.startOffset)&&Q(this.host,this.range.endContainer,this.range.endOffset)}},{key:"getTextRange",value:function(){return R(this.range,this.host)}},{key:"toString",value:function(){return this.range.toString()}},{key:"isWrappable",value:function(){return He(this.range)}},{key:"getRects",value:function(){return this.range.getClientRects()}},{key:"link",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e&&(t.href=e);var n=this.createElement(c.linkMarkup.name,c.linkMarkup.attribs);for(var r in t){var i=t[r];void 0!==i&&(null===i?n.removeAttribute(r):n.setAttribute(r,i))}c.linkMarkup.trim&&this.trimRange(),this.forceWrap(n)}},{key:"trimRange",value:function(){var e=this.range.toString(),t=e.search(/\S|$/),n=e.search(/\S[\s]+$/),r=-1===n?0:e.length-(n+1),i=zt(L({root:this.range.commonAncestorContainer,startContainer:this.range.startContainer,startOffset:this.range.startOffset,whitespacesOnTheLeft:t}),2),o=i[0],a=i[1];this.range.setStart(o,a);var s=zt(M({root:this.range.commonAncestorContainer,endContainer:this.range.endContainer,endOffset:this.range.endOffset,whitespacesOnTheRight:r}),2),u=s[0],c=s[1];this.range.setEnd(u,c)}},{key:"unlink",value:function(){this.removeFormatting(c.linkMarkup.name)}},{key:"toggleLink",value:function(e,t){var n=this.getTagsByName(c.linkMarkup.name);if(n.length>=1){var r=n[0];this.isExactSelection(r,"visible")?this.unlink():this.expandTo(r)}else this.link(e,t)}},{key:"highlightComment",value:function(e){var t=e.highlightId,n=e.textRange;rn.highlightRange(this.host,t,n.text,n.start,n.end,void 0,"comment")}},{key:"highlight",value:function(e){e.highlightId;var t=this.textBefore(),n=this.text(),r=rn.createMarkerNode('<span class="highlight-comment"></span>',this.win);r.setAttribute("data-match",n);var i={startIndex:t.length,endIndex:t.length+n.length,match:n,marker:r};Qt.highlightMatches(this.host,[i])}},{key:"toggle",value:function(e){it(this.host)||this.range.collapsed||(e=this.adoptElement(e),this.range=Fe(this.host,this.range,e),this.setVisibleSelection())}},{key:"toggleCustom",value:function(e){var t=e.tagName,n=e.attributes,r=e.trim,i=void 0!==r&&r,o=this.createElement(t,n);i&&this.trimRange(),this.toggle(o)}},{key:"makeCustom",value:function(e){var t=e.tagName,n=e.attributes,r=e.trim,i=void 0!==r&&r,o=this.createElement(t,n);i&&this.trimRange(),this.forceWrap(o)}},{key:"makeBold",value:function(){var e=this.createElement(c.boldMarkup.name,c.boldMarkup.attribs);c.boldMarkup.trim&&this.trimRange(),this.forceWrap(e)}},{key:"toggleBold",value:function(){var e=this.createElement(c.boldMarkup.name,c.boldMarkup.attribs);c.boldMarkup.trim&&this.trimRange(),this.toggle(e)}},{key:"giveEmphasis",value:function(){var e=this.createElement(c.italicMarkup.name,c.italicMarkup.attribs);c.italicMarkup.trim&&this.trimRange(),this.forceWrap(e)}},{key:"toggleEmphasis",value:function(){var e=this.createElement(c.italicMarkup.name,c.italicMarkup.attribs);c.italicMarkup.trim&&this.trimRange(),this.toggle(e)}},{key:"makeUnderline",value:function(){var e=this.createElement(c.underlineMarkup.name,c.underlineMarkup.attribs);c.underlineMarkup.trim&&this.trimRange(),this.forceWrap(e)}},{key:"toggleUnderline",value:function(){var e=this.createElement(c.underlineMarkup.name,c.underlineMarkup.attribs);c.underlineMarkup.trim&&this.trimRange(),this.toggle(e)}},{key:"insertCharacter",value:function(e){var t=this.deleteContent(),n=t.createTextNode(e);return t.insertBefore(n),t.setVisibleSelection(),t}},{key:"surround",value:function(e,t){this.range=Qe(this.host,this.range,e,t),this.setVisibleSelection()}},{key:"removeSurround",value:function(e,t){this.range=Xe(this.host,this.range,e),this.range=Xe(this.host,this.range,t),this.setVisibleSelection()}},{key:"removeChars",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=0;t<e.length;t++){var n=e[t];this.range=Xe(this.host,this.range,n)}this.setVisibleSelection()}},{key:"toggleSurround",value:function(e,t){this.containsString(e)&&this.containsString(t)?this.removeSurround(e,t):this.surround(e,t)}},{key:"removeFormatting",value:function(e){this.range=Ue(this.host,this.range,e),this.setVisibleSelection()}},{key:"deleteExactSurroundingTags",value:function(){var e,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return on(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?on(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(this.getAncestorTags().reverse());try{for(n.s();!(e=n.n()).done;){var r=e.value;if(this.isExactSelection(r)){r.remove();break}}}catch(e){n.e(e)}finally{n.f()}return new t(this.host,this.range)}},{key:"deleteContainedTags",value:function(){return this.getContainedTags().forEach((function(e){return e.remove()})),new t(this.host,this.range)}},{key:"deleteContent",value:function(){return this.range.deleteContents(),new Wt(this.host,this.range)}},{key:"expandTo",value:function(e){this.range=De(this.host,this.range,e),this.setVisibleSelection()}},{key:"collapseAtBeginning",value:function(e){return this.range.collapse(!0),this.setVisibleSelection(),new Wt(this.host,this.range)}},{key:"collapseAtEnd",value:function(e){return this.range.collapse(!1),this.setVisibleSelection(),new Wt(this.host,this.range)}},{key:"forceWrap",value:function(e){it(this.host)||this.range.collapsed||(e=this.adoptElement(e),this.range=Pe(this.host,this.range,e),this.setVisibleSelection())}},{key:"isExactSelection",value:function(e,t){return Ie(this.range,e,t)}},{key:"containsString",value:function(e){return Ge(this.range,e)}},{key:"deleteCharacter",value:function(e){this.range=Xe(this.host,this.range,e),this.setVisibleSelection()}}]),t}(Wt),sn=function(){function e(t,n){i(this,e),this.host=t&&t.jquery?t[0]:t,this.range=n,this.isAnythingSelected=void 0!==n,this.isCursor=this.isAnythingSelected&&n.collapsed,this.isSelection=this.isAnythingSelected&&!this.isCursor}return u(e,[{key:"getCursor",value:function(){if(this.isCursor)return new Wt(this.host,this.range)}},{key:"getSelection",value:function(){if(this.isSelection)return new an(this.host,this.range)}},{key:"forceCursor",value:function(){return this.isSelection?this.getSelection().deleteContent():this.getCursor()}},{key:"isDifferentFrom",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new e,n=this.range,r=t.range;return n&&r?!B(n,r):!(!n&&!r)}}]),e}(),un=function(){function e(t,n){i(this,e),this.dispatcher=t,this.win=n||window,this.selection=void 0,this.currentSelection=void 0,this.currentRange=void 0}return u(e,[{key:"syncSelection",value:function(){try{this.selection=E(this.win)}catch(e){return!1}return!0}},{key:"getRangeContainer",value:function(){var e,t=this.syncSelection();if(null!==(e=this.selection)&&void 0!==e&&e.rangeCount&&t){var n=this.selection.getRangeAt(0),r=D(n.commonAncestorContainer);if(r)return new sn(r,n)}return new sn}},{key:"getFreshRange",value:function(){return this.getRangeContainer()}},{key:"getFreshSelection",value:function(){var e=this.getRangeContainer();return e.isCursor?e.getCursor(this.win):e.getSelection(this.win)}},{key:"getSelection",value:function(){return this.currentSelection}},{key:"forceCursor",value:function(){return this.getRangeContainer().forceCursor()}},{key:"selectionChanged",value:function(){var e=this.getRangeContainer();if(e.isDifferentFrom(this.currentRange)){var t=this.currentSelection;this.currentRange=e,t&&(t.isCursor&&!this.currentRange.isCursor?this.dispatcher.notify("cursor",t.host):t.isSelection&&!this.currentRange.isSelection&&this.dispatcher.notify("selection",t.host)),this.currentRange.isCursor?(this.currentSelection=new Wt(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("cursor",this.currentSelection.host,this.currentSelection)):this.currentRange.isSelection?(this.currentSelection=new an(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("selection",this.currentSelection.host,this.currentSelection)):this.currentSelection=void 0}}}]),e}(),cn=function(){function e(t){i(this,e),Pt(this),this.selectionWatcher=t}return u(e,[{key:"dispatchKeyEvent",value:function(e,t,n){switch(e.keyCode){case this.key.left:return this.notify(t,"left",e);case this.key.right:return this.notify(t,"right",e);case this.key.up:return this.notify(t,"up",e);case this.key.down:return this.notify(t,"down",e);case this.key.tab:return e.shiftKey?this.notify(t,"shiftTab",e):this.notify(t,"tab",e);case this.key.esc:return this.notify(t,"esc",e);case this.key.backspace:return this.preventContenteditableBug(t,e),this.notify(t,"backspace",e);case this.key.delete:return this.preventContenteditableBug(t,e),this.notify(t,"delete",e);case this.key.enter:return e.shiftKey?this.notify(t,"shiftEnter",e):this.notify(t,"enter",e);case this.key.ctrl:case this.key.shift:case this.key.alt:case 224:case 17:case 91:case 93:return;default:if(e.keyCode===this.key.b&&(e.ctrlKey||e.metaKey))return this.notify(t,"bold",e);if(e.keyCode===this.key.i&&(e.ctrlKey||e.metaKey))return this.notify(t,"italic",e);if(this.preventContenteditableBug(t,e),!n)return;if(!e.ctrlKey&&!e.metaKey)return this.notify(t,"character",e)}}},{key:"preventContenteditableBug",value:function(t,n){if(Ht&&!n.ctrlKey&&!n.metaKey){var r=this.selectionWatcher.getFreshRange();if(r.isSelection){var i=e.getNodeToRemove(r.range,t);i&&i.remove()}}}}],[{key:"getNodeToRemove",value:function(t,n){if(0===t.startOffset){var r=t.startContainer;if(r.nodeType===y&&(r=r.parentNode),r!==n){var i=A();if(i.setStartBefore(r.firstChild),i.setEndAfter(r.lastChild),a=t,!((o=i).compareBoundaryPoints(Range.START_TO_START,a)<=0&&o.compareBoundaryPoints(Range.END_TO_END,a)>=0)){var o,a;if(t.startContainer.nodeType===y){var s=[y,p],u=r.firstChild;do{if(-1!==s.indexOf(u.nodeType))break}while(u=u.nextSibling);if(u!==t.startContainer)return}var c=t.cloneRange();return c.setStartBefore(r),e.getNodeToRemove(c,n)||r}}}}}]),e}();function ln(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return fn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fn(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function fn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}cn.key=cn.prototype.key={left:37,up:38,right:39,down:40,tab:9,esc:27,backspace:8,delete:46,enter:13,shift:16,ctrl:17,alt:18,b:66,i:73};var hn=!1,dn=function(){function e(t){i(this,e);var n=t.win;Pt(this,t),this.supportsInputEvent=!1,this.document=n.document,this.config=t.config,this.editable=t,this.editableSelector=t.editableSelector,this.selectionWatcher=new un(this,n),this.keyboard=new cn(this.selectionWatcher),this.activeListeners=[],this.setup(),this.getEditableBlockByEvent=function(e){return S(e.target,t.editableSelector)}}return u(e,[{key:"setupDocumentListener",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r={event:e,listener:t.bind(this),capture:n};return this.activeListeners.push(r),this.document.addEventListener(e,r.listener,n),this}},{key:"setup",value:function(){this.setupKeyboardEvents(),this.setupEventListeners()}},{key:"unload",value:function(){this.off();var e,t=ln(this.activeListeners);try{for(t.s();!(e=t.n()).done;){var n=e.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(e){t.e(e)}finally{t.f()}this.activeListeners.length=0}},{key:"suspend",value:function(){if(!this.suspended){this.suspended=!0;var e,t=ln(this.activeListeners);try{for(t.s();!(e=t.n()).done;){var n=e.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(e){t.e(e)}finally{t.f()}this.activeListeners.length=0}}},{key:"continue",value:function(){this.suspended&&(this.suspended=!1,this.setupEventListeners())}},{key:"setupEventListeners",value:function(){this.setupElementListeners(),this.setupKeydownListener(),Ft?this.setupSelectionChangeListeners():this.setupSelectionChangeFallbackListeners()}},{key:"setupElementListeners",value:function(){this.setupDocumentListener("focus",(function(e){var t=this.getEditableBlockByEvent(e);t&&(e.target.getAttribute(c.pastingAttribute)||(this.selectionWatcher.syncSelection(),this.notify("focus",t)))}),!0).setupDocumentListener("blur",(function(e){var t=this.getEditableBlockByEvent(e);t&&(t.getAttribute(c.pastingAttribute)||this.notify("blur",t))}),!0).setupDocumentListener("copy",(function(e){var t=this.getEditableBlockByEvent(e);if(t){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&this.notify("clipboard",t,"copy",n)}})).setupDocumentListener("cut",(function(e){var t=this.getEditableBlockByEvent(e);if(t){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&(this.notify("clipboard",t,"cut",n),this.triggerChangeEvent(t))}})).setupDocumentListener("paste",(function(e){var t=this.getEditableBlockByEvent(e);if(t){e.preventDefault();var n,r=this.selectionWatcher.getFreshSelection(),i=e.clipboardData.getData("text/html")||e.clipboardData.getData("text/plain"),o=Bt(t,r,i),a=o.blocks,s=o.cursor;a.length?(n=e.target.innerText,/\S+\s{1}$/.test(n)&&s.retainVisibleSelection((function(){t.innerHTML=function(e,t,n){if(!e)return"";var r=(e="".concat(e)).lastIndexOf(t);return-1===r?e:"".concat(e.slice(0,r)).concat(" ").concat(e.slice(r+6))}(t.innerHTML," ")})),this.notify("paste",t,a,s),this.notify("change",t)):s.setVisibleSelection()}})).setupDocumentListener("input",(function(e){var t=this.getEditableBlockByEvent(e);t&&(hn?this.notify("change",t):hn=!0)})).setupDocumentListener("formatEditable",(function(e){var t=this.getEditableBlockByEvent(e);t&&this.notify("change",t)}))}},{key:"triggerChangeEvent",value:function(e){hn||this.notify("change",e)}},{key:"dispatchSwitchEvent",value:function(e,t,n){if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)){var r=this.selectionWatcher.getFreshSelection();r&&!r.isSelection&&(this.switchContext?this.switchContext.events=["cursor"]:this.switchContext={positionX:r.getBoundingClientRect().left,events:["cursor"]},"up"===n&&r.isAtFirstLine()&&(e.preventDefault(),e.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",t,n,r)),"down"===n&&r.isAtLastLine()&&(e.preventDefault(),e.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",t,n,r)))}}},{key:"setupKeydownListener",value:function(){this.setupDocumentListener("keydown",(function(e){var t=this.getEditableBlockByEvent(e);if(t){var n=!hn;this.keyboard.dispatchKeyEvent(e,t,n)}}),!0)}},{key:"setupKeyboardEvents",value:function(){var e=this;this.keyboard.on("up",(function(t){e.dispatchSwitchEvent(t,this,"up")})).on("down",(function(t){e.dispatchSwitchEvent(t,this,"down")})).on("backspace",(function(t){var n=e.selectionWatcher.getFreshRange();if(!n.isCursor)return e.triggerChangeEvent(this);var r=n.getCursor();if(!r.isAtBeginning())return e.triggerChangeEvent(this);t.preventDefault(),t.stopPropagation(),e.notify("merge",this,"before",r)})).on("delete",(function(t){var n=e.selectionWatcher.getFreshRange();if(!n.isCursor)return e.triggerChangeEvent(this);var r=n.getCursor();if(!r.isAtTextEnd())return e.triggerChangeEvent(this);t.preventDefault(),t.stopPropagation(),e.notify("merge",this,"after",r)})).on("enter",(function(t){t.preventDefault(),t.stopPropagation();var n=e.selectionWatcher.getFreshRange().forceCursor();n.isAtTextEnd()?e.notify("insert",this,"after",n):n.isAtBeginning()?e.notify("insert",this,"before",n):e.notify("split",this,n.before(),n.after(),n)})).on("shiftEnter",(function(t){t.preventDefault(),t.stopPropagation();var n=e.selectionWatcher.forceCursor();e.notify("newline",this,n)})).on("bold",(function(t){t.preventDefault(),t.stopPropagation();var n=e.selectionWatcher.getFreshSelection();n.isSelection&&e.notify("toggleBold",n)})).on("italic",(function(t){t.preventDefault(),t.stopPropagation();var n=e.selectionWatcher.getFreshSelection();n.isSelection&&e.notify("toggleEmphasis",n)})).on("character",(function(t){e.notify("change",this)}))}},{key:"setupSelectionChangeListeners",value:function(){var e=this,t=!1,n=!1,r=this.selectionWatcher;this.setupDocumentListener("selectionchange",(function(i){var o=e.selectionWatcher.getFreshSelection();o&&o.isSelection&&o.isAtBeginning()&&o.isAtEnd()?e.notify("selectToBoundary",o.host,i,"both"):o&&o.isSelection&&o.isAtBeginning()?e.notify("selectToBoundary",o.host,i,"start"):o&&o.isSelection&&o.isAtEnd()&&e.notify("selectToBoundary",o.host,i,"end"),n?t=!0:r.selectionChanged()})),this.setupDocumentListener("mousedown",(function(e){this.getEditableBlockByEvent(e)&&(!1===this.config.mouseMoveSelectionChanges&&(n=!0,setTimeout((function(){return r.selectionChanged()}),0)),this.document.addEventListener("mouseup",(function(){n=!1,t&&(t=!1,r.selectionChanged())}),{capture:!0,once:!0}))}))}},{key:"setupSelectionChangeFallbackListeners",value:function(){var e=this;this.setupDocumentListener("mouseup",(function(){setTimeout((function(){return e.selectionWatcher.selectionChanged()}),0)})),this.setupDocumentListener("keyup",(function(t){e.getEditableBlockByEvent(t)&&e.selectionWatcher.selectionChanged()}))}}]),e}();const gn=function(e,t){return e===t||e!=e&&t!=t},vn=function(e,t){for(var n=e.length;n--;)if(gn(e[n][0],t))return n;return-1};var pn=Array.prototype.splice;function yn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}yn.prototype.clear=function(){this.__data__=[],this.size=0},yn.prototype.delete=function(e){var t=this.__data__,n=vn(t,e);return!(n<0||(n==t.length-1?t.pop():pn.call(t,n,1),--this.size,0))},yn.prototype.get=function(e){var t=this.__data__,n=vn(t,e);return n<0?void 0:t[n][1]},yn.prototype.has=function(e){return vn(this.__data__,e)>-1},yn.prototype.set=function(e,t){var n=this.__data__,r=vn(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};const mn=yn,bn="object"==typeof global&&global&&global.Object===Object&&global;var kn="object"==typeof self&&self&&self.Object===Object&&self;const Cn=bn||kn||Function("return this")(),wn=Cn.Symbol;var Sn=Object.prototype,An=Sn.hasOwnProperty,En=Sn.toString,Tn=wn?wn.toStringTag:void 0;var xn=Object.prototype.toString;var Nn=wn?wn.toStringTag:void 0;const On=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Nn&&Nn in Object(e)?function(e){var t=An.call(e,Tn),n=e[Tn];try{e[Tn]=void 0;var r=!0}catch(e){}var i=En.call(e);return r&&(t?e[Tn]=n:delete e[Tn]),i}(e):function(e){return xn.call(e)}(e)},_n=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},jn=function(e){if(!_n(e))return!1;var t=On(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},Rn=Cn["__core-js_shared__"];var Bn,Ln=(Bn=/[^.]+$/.exec(Rn&&Rn.keys&&Rn.keys.IE_PROTO||""))?"Symbol(src)_1."+Bn:"";var Mn=Function.prototype.toString;var In=/^\[object .+?Constructor\]$/,Dn=Function.prototype,Fn=Object.prototype,Hn=Dn.toString,Pn=Fn.hasOwnProperty,Vn=RegExp("^"+Hn.call(Pn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const Wn=function(e){return!(!_n(e)||(t=e,Ln&&Ln in t))&&(jn(e)?Vn:In).test(function(e){if(null!=e){try{return Mn.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t},qn=function(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return Wn(n)?n:void 0},Un=qn(Cn,"Map"),zn=qn(Object,"create");var $n=Object.prototype.hasOwnProperty;var Kn=Object.prototype.hasOwnProperty;function Qn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Qn.prototype.clear=function(){this.__data__=zn?zn(null):{},this.size=0},Qn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Qn.prototype.get=function(e){var t=this.__data__;if(zn){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return $n.call(t,e)?t[e]:void 0},Qn.prototype.has=function(e){var t=this.__data__;return zn?void 0!==t[e]:Kn.call(t,e)},Qn.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=zn&&void 0===t?"__lodash_hash_undefined__":t,this};const Xn=Qn,Gn=function(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map};function Yn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Yn.prototype.clear=function(){this.size=0,this.__data__={hash:new Xn,map:new(Un||mn),string:new Xn}},Yn.prototype.delete=function(e){var t=Gn(this,e).delete(e);return this.size-=t?1:0,t},Yn.prototype.get=function(e){return Gn(this,e).get(e)},Yn.prototype.has=function(e){return Gn(this,e).has(e)},Yn.prototype.set=function(e,t){var n=Gn(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};const Jn=Yn;function Zn(e){var t=this.__data__=new mn(e);this.size=t.size}Zn.prototype.clear=function(){this.__data__=new mn,this.size=0},Zn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Zn.prototype.get=function(e){return this.__data__.get(e)},Zn.prototype.has=function(e){return this.__data__.has(e)},Zn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof mn){var r=n.__data__;if(!Un||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Jn(r)}return n.set(e,t),this.size=n.size,this};const er=Zn,tr=function(){try{var e=qn(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),nr=function(e,t,n){"__proto__"==t&&tr?tr(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},rr=function(e,t,n){(void 0!==n&&!gn(e[t],n)||void 0===n&&!(t in e))&&nr(e,t,n)},ir=function(e,t,n){for(var r=-1,i=Object(e),o=n(e),a=o.length;a--;){var s=o[++r];if(!1===t(i[s],s,i))break}return e};var or="object"==typeof exports&&exports&&!exports.nodeType&&exports,ar=or&&"object"==typeof module&&module&&!module.nodeType&&module,sr=ar&&ar.exports===or?Cn.Buffer:void 0,ur=sr?sr.allocUnsafe:void 0;const cr=Cn.Uint8Array,lr=function(e,t){var n,r,i=t?(n=e.buffer,r=new n.constructor(n.byteLength),new cr(r).set(new cr(n)),r):e.buffer;return new e.constructor(i,e.byteOffset,e.length)};var fr=Object.create;const hr=function(){function e(){}return function(t){if(!_n(t))return{};if(fr)return fr(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}(),dr=(gr=Object.getPrototypeOf,vr=Object,function(e){return gr(vr(e))});var gr,vr,pr=Object.prototype;const yr=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||pr)},mr=function(e){return null!=e&&"object"==typeof e},br=function(e){return mr(e)&&"[object Arguments]"==On(e)};var kr=Object.prototype,Cr=kr.hasOwnProperty,wr=kr.propertyIsEnumerable;const Sr=br(function(){return arguments}())?br:function(e){return mr(e)&&Cr.call(e,"callee")&&!wr.call(e,"callee")},Ar=Array.isArray,Er=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},Tr=function(e){return null!=e&&Er(e.length)&&!jn(e)};var xr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Nr=xr&&"object"==typeof module&&module&&!module.nodeType&&module,Or=Nr&&Nr.exports===xr?Cn.Buffer:void 0;const _r=(Or?Or.isBuffer:void 0)||function(){return!1};var jr=Function.prototype,Rr=Object.prototype,Br=jr.toString,Lr=Rr.hasOwnProperty,Mr=Br.call(Object);var Ir={};Ir["[object Float32Array]"]=Ir["[object Float64Array]"]=Ir["[object Int8Array]"]=Ir["[object Int16Array]"]=Ir["[object Int32Array]"]=Ir["[object Uint8Array]"]=Ir["[object Uint8ClampedArray]"]=Ir["[object Uint16Array]"]=Ir["[object Uint32Array]"]=!0,Ir["[object Arguments]"]=Ir["[object Array]"]=Ir["[object ArrayBuffer]"]=Ir["[object Boolean]"]=Ir["[object DataView]"]=Ir["[object Date]"]=Ir["[object Error]"]=Ir["[object Function]"]=Ir["[object Map]"]=Ir["[object Number]"]=Ir["[object Object]"]=Ir["[object RegExp]"]=Ir["[object Set]"]=Ir["[object String]"]=Ir["[object WeakMap]"]=!1;var Dr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Fr=Dr&&"object"==typeof module&&module&&!module.nodeType&&module,Hr=Fr&&Fr.exports===Dr&&bn.process,Pr=function(){try{return Fr&&Fr.require&&Fr.require("util").types||Hr&&Hr.binding&&Hr.binding("util")}catch(e){}}(),Vr=Pr&&Pr.isTypedArray;const Wr=Vr?function(e){return function(t){return e(t)}}(Vr):function(e){return mr(e)&&Er(e.length)&&!!Ir[On(e)]},qr=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};var Ur=Object.prototype.hasOwnProperty;const zr=function(e,t,n){var r=e[t];Ur.call(e,t)&&gn(r,n)&&(void 0!==n||t in e)||nr(e,t,n)};var $r=/^(?:0|[1-9]\d*)$/;const Kr=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&$r.test(e))&&e>-1&&e%1==0&&e<t};var Qr=Object.prototype.hasOwnProperty;const Xr=function(e,t){var n=Ar(e),r=!n&&Sr(e),i=!n&&!r&&_r(e),o=!n&&!r&&!i&&Wr(e),a=n||r||i||o,s=a?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],u=s.length;for(var c in e)!t&&!Qr.call(e,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Kr(c,u))||s.push(c);return s};var Gr=Object.prototype.hasOwnProperty;const Yr=function(e){if(!_n(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=yr(e),n=[];for(var r in e)("constructor"!=r||!t&&Gr.call(e,r))&&n.push(r);return n},Jr=function(e){return Tr(e)?Xr(e,!0):Yr(e)},Zr=function(e){return function(e,t,n,r){var i=!n;n||(n={});for(var o=-1,a=t.length;++o<a;){var s=t[o],u=r?r(n[s],e[s],s,n,e):void 0;void 0===u&&(u=e[s]),i?nr(n,s,u):zr(n,s,u)}return n}(e,Jr(e))},ei=function(e,t,n,r,i,o,a){var s,u=qr(e,n),c=qr(t,n),l=a.get(c);if(l)rr(e,n,l);else{var f=o?o(u,c,n+"",e,t,a):void 0,h=void 0===f;if(h){var d=Ar(c),g=!d&&_r(c),v=!d&&!g&&Wr(c);f=c,d||g||v?Ar(u)?f=u:mr(s=u)&&Tr(s)?f=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}(u):g?(h=!1,f=function(e,t){if(t)return e.slice();var n=e.length,r=ur?ur(n):new e.constructor(n);return e.copy(r),r}(c,!0)):v?(h=!1,f=lr(c,!0)):f=[]:function(e){if(!mr(e)||"[object Object]"!=On(e))return!1;var t=dr(e);if(null===t)return!0;var n=Lr.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Br.call(n)==Mr}(c)||Sr(c)?(f=u,Sr(u)?f=Zr(u):_n(u)&&!jn(u)||(f=function(e){return"function"!=typeof e.constructor||yr(e)?{}:hr(dr(e))}(c))):h=!1}h&&(a.set(c,f),i(f,c,r,o,a),a.delete(c)),rr(e,n,f)}},ti=function e(t,n,r,i,o){t!==n&&ir(n,(function(a,s){if(o||(o=new er),_n(a))ei(t,n,s,r,e,i,o);else{var u=i?i(qr(t,s),a,s+"",t,n,o):void 0;void 0===u&&(u=a),rr(t,s,u)}}),Jr)},ni=function(e){return e};var ri=Math.max;const ii=tr?function(e,t){return tr(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:ni;var oi=Date.now;const ai=function(e){var t=0,n=0;return function(){var r=oi(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(ii),si=function(e,t){return ai(function(e,t,n){return t=ri(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=ri(r.length-t,0),a=Array(o);++i<o;)a[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(a),function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(e,this,s)}}(e,t,ni),e+"")},ui=(ci=function(e,t,n){ti(e,t,n)},si((function(e,t){var n=-1,r=t.length,i=r>1?t[r-1]:void 0,o=r>2?t[2]:void 0;for(i=ci.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(e,t,n){if(!_n(n))return!1;var r=typeof t;return!!("number"==r?Tr(n)&&Kr(t,n.length):"string"==r&&t in n)&&gn(n[t],e)}(t[0],t[1],o)&&(i=r<3?void 0:i,r=1),e=Object(e);++n<r;){var a=t[n];a&&ci(e,a,n)}return e})));var ci,li=function(){function e(t){i(this,e),this.spellcheckService=t}return u(e,[{key:"check",value:function(e,t){if(!e)return t(null);var n=ye(e);this.spellcheckService(n,(function(e){e&&e.length>0?t(null,e):t(null)}))}}]),e}(),fi={A0:"no-break space",2e3:"en quad",2001:"em quad",2002:"en space",2003:"em space",2004:"three-per-em space",2005:"four-per-em space",2006:"six-per-em space",2007:"figure space",2008:"punctuation space",2009:"thin space","200A":"hair space","202F":"narrow no-break space","205F":"medium mathematical space",3e3:"ideographic space"},hi=new RegExp("[".concat("\\u2000-\\u200A\\u202F\\u205F\\u3000","]"),"g"),di=function(){function e(t){i(this,e),this.marker=t}return u(e,[{key:"findMatches",value:function(e){var t=this;if(e)return ut(e.matchAll(hi)).map((function(e){return t.prepareMatch(e)}))}},{key:"prepareMatch",value:function(e){var t,n=e.index,r=(t=e[0].charCodeAt(0),"".concat(t.toString(16).toUpperCase())),i=fi[r];return{startIndex:n,endIndex:n+e.length,match:e[0],title:"".concat(i," (\\u").concat(r,")"),marker:this.marker}}}]),e}(),gi=function(){function e(){i(this,e),this.matches=[]}return u(e,[{key:"addMatches",value:function(e){null!=e&&e.length&&(this.matches=function(e,t){for(var n,r=e.length,i=t.length,o=-1,a=[],s={a1:e,i1:0,a2:t,i2:0};s.i1<r||s.i2<i;)(n=vi(s)).startIndex>=o&&a.push(n),o=n.endIndex;return a}(this.matches,e))}}]),e}();function vi(e){var t=e.i1,n=e.i2,r=e.a1[t],i=e.a2[n];return r&&i&&r.startIndex<i.startIndex?(e.i1=t+1,r):r&&i?(e.i2=n+1,i):r?(e.i1=t+1,r):i?(e.i2=n+1,i):void 0}function pi(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return yi(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yi(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function yi(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var mi=function(){function e(t,n,r){i(this,e),this.editable=t,this.win=t.win,this.focusedEditableHost=void 0,this.currentlyCheckedEditableHost=void 0,this.timeout={},this.config=ui({},{checkOnInit:!1,checkOnFocus:!1,checkOnChange:!0,throttle:1e3,removeOnCorrection:!0,spellcheck:{marker:'<span class="highlight-spellcheck"></span>',throttle:1e3,spellcheckService:function(){}},whitespace:{marker:'<span class="highlight-whitespace"></span>'}},n);var o=this.config.spellcheck.spellcheckService,a=this.config.spellcheck.marker,s=this.config.whitespace.marker,u=rn.createMarkerNode(s,"whitespace",this.win);this.spellcheckMarkerNode=rn.createMarkerNode(a,"spellcheck",this.win),this.spellcheckService=new li(o),this.whitespace=new di(u),this.setupListeners()}return u(e,[{key:"setupListeners",value:function(){var e=this;this.config.checkOnFocus&&(this.editable.on("focus",(function(){return e.onFocus.apply(e,arguments)})),this.editable.on("blur",(function(){return e.onBlur.apply(e,arguments)}))),(this.config.checkOnChange||this.config.removeOnCorrection)&&this.editable.on("change",(function(){return e.onChange.apply(e,arguments)})),this.config.checkOnInit&&this.editable.on("init",(function(){return e.onInit.apply(e,arguments)}))}},{key:"onInit",value:function(e){this.highlight(e)}},{key:"onFocus",value:function(e){this.focusedEditableHost!==e&&(this.focusedEditableHost=e,this.editableHasChanged(e))}},{key:"onBlur",value:function(e){this.focusedEditableHost===e&&(this.focusedEditableHost=void 0)}},{key:"onChange",value:function(e){this.config.checkOnChange&&this.editableHasChanged(e,this.config.throttle),this.config.removeOnCorrection&&this.removeHighlightsAtCursor(e)}},{key:"editableHasChanged",value:function(e,t){var n=this;this.timeout.id&&this.timeout.editableHost===e&&clearTimeout(this.timeout.id);var r=setTimeout((function(){n.highlight(e),n.timeout={}}),t||0);this.timeout={id:r,editableHost:e}}},{key:"highlight",value:function(e){var t=this,n=Qt.extractText(e);this.spellcheckService.check(n,(function(n,r){if(!n&&e.isConnected){var i=Qt.extractText(e),o=new gi,a=function(e,t,n){return Xt(e,t,"word",n)}(i,r,t.spellcheckMarkerNode);o.addMatches(a),a=t.whitespace.findMatches(i),o.addMatches(a),t.safeHighlightMatches(e,o.matches)}}))}},{key:"safeHighlightMatches",value:function(e,t){var n=this,r=this.editable.getSelection(e);r?r.retainVisibleSelection((function(){n.highlightMatches(e,t)})):this.highlightMatches(e,t),this.editable.dispatcher&&this.editable.dispatcher.notify("spellcheckUpdated",e)}},{key:"highlightMatches",value:function(e,t){this.removeHighlights(e),t&&t.length>0&&Qt.highlightMatches(e,t)}},{key:"removeHighlights",value:function(e){e=C(e,this.win.document);var t,n=pi(k('[data-highlight="spellcheck"], [data-highlight="whitespace"]',e));try{for(n.s();!(t=n.n()).done;)We(t.value)}catch(e){n.e(e)}finally{n.f()}}},{key:"removeHighlightsAtCursor",value:function(e){e=C(e,this.win.document);var t=this.editable.getSelection(e);if(t&&t.isCursor){var n,r=t.range.startContainer;r.nodeType===y&&(r=r.parentNode);do{if(r===e)return;var i=r.getAttribute("data-highlight");if("spellcheck"===i||"whitespace"===i){n=r.getAttribute("data-word-id");break}}while(r=r.parentNode);n&&t.retainVisibleSelection((function(){var t,r=pi(k('[data-word-id="'.concat(n,'"]'),e));try{for(r.s();!(t=r.n()).done;)We(t.value)}catch(e){r.e(e)}finally{r.f()}}))}}}]),e}();function bi(){if(!1!==c.log&&e.g.console){var t=1===arguments.length?arguments[0]:Array.from(arguments);return 1!==arguments.length&&"trace"===t[t.length-1]&&(t.pop(),console.trace&&console.trace()),console.log(t)}}function ki(e){return ut(new b(e,"getNextTextNode"))}function Ci(e){for(var t,n=e.textNodes,r=e.absOffset,i=0,o=0,a=0;a<n.length;a++){var s=n[a];if(r<=i+s.textContent.length){t=s,o=r-i;break}i+=s.textContent.length}return{node:t,relativeOffset:o}}function wi(e){e.rightLimit=e.currentOffset,e.currentOffset=Math.floor((e.currentOffset+e.leftLimit)/2)}function Si(e){e.leftLimit=e.currentOffset,e.currentOffset=Math.ceil((e.currentOffset+e.rightLimit)/2)}function Ai(e){var t=Ci({textNodes:e.textNodes,absOffset:e.offset}),n=t.node,r=t.relativeOffset,i=n.ownerDocument.createRange();return i.setStart(n,r),i.collapse(!0),i}function Ei(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return Ti(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ti(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Ti(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var xi=function(){function e(t){i(this,e);var n,r={window,defaultBehavior:!0,mouseMoveSelectionChanges:!1,browserSpellcheck:!0};this.config=Object.assign(r,t),this.win=this.config.window,this.editableSelector=".".concat(c.editableClass),this.dispatcher=new dn(this),!0===this.config.defaultBehavior&&this.dispatcher.on((n=function(e){var t=e.win.document;return{focus:function(e){H(e)&&e.appendChild(t.createTextNode("\ufeff"))},blur:function(e){t.activeElement!==e&&me(e)},selection:function(e,t){bi(t?"Default selection behavior":"Default selection empty behavior")},cursor:function(e,t){bi(t?"Default cursor behavior":"Default cursor empty behavior")},newline:function(e,n){if(n.isAtTextEnd()){var r,i=t.createElement("br");n.insertBefore(i),(null===(r=i.nextSibling)||void 0===r?void 0:r.nodeType)===y&&"\ufeff"===i.nextSibling.textContent[0]||n.insertAfter(t.createTextNode("\ufeff"))}else n.insertBefore(t.createElement("br"));n.setVisibleSelection()},insert:function(e,t,n){var r=e.parentNode,i=e.cloneNode(!1);switch(i.id&&i.removeAttribute("id"),t){case"before":r.insertBefore(i,e),e.focus();break;case"after":r.insertBefore(i,e.nextSibling),i.focus()}},split:function(e,t,n,r){var i=e.cloneNode(!1);for(i.appendChild(t),e.parentNode.insertBefore(i,e);e.firstChild;)e.removeChild(e.firstChild);e.appendChild(n),ve(i),ve(e),e.focus()},merge:function(t,n,r){var i,o;switch(n){case"before":i=nt(t),o=t;break;case"after":i=t,o=tt(t)}i&&o&&(r=i.childNodes.length>0?e.appendTo(i,o.innerHTML):e.prependTo(i,o.innerHTML),o.remove(),r.save(),ve(i),r.restore(),r.setVisibleSelection())},empty:function(e){bi("Default empty behavior")},switch:function(e,t,n){switch(t){case"before":var r=nt(e);r&&(n.moveAtTextEnd(r),n.setVisibleSelection());break;case"after":var i=tt(e);i&&(n.moveAtBeginning(i),n.setVisibleSelection())}},move:function(e,t,n){bi("Default move behavior")},paste:function(t,n,r){if(0!==n.length){if(r.insertBefore(n.shift()),0===n.length)return r.setVisibleSelection();var i=t.parentNode,o=t;n.forEach((function(e){var n=t.cloneNode(!1);n.id&&n.removeAttribute("id");var r=Ce(e);n.appendChild(r),i.insertBefore(n,o.nextSibling),o=n})),e.createCursorAtEnd(o).setVisibleSelection()}},clipboard:function(e,t,n){bi("Default clipboard behavior")},toggleBold:function(e){e.toggleBold()},toggleEmphasis:function(e){e.toggleEmphasis()}}}(this),{focus:function(e){n.focus(e)},blur:function(e){n.blur(e)},flow:function(e,t){n.flow(e,t)},selection:function(e,t){n.selection(e,t)},cursor:function(e,t){n.cursor(e,t)},newline:function(e,t){n.newline(e,t)},split:function(e,t,r,i){n.split(e,t,r,i)},insert:function(e,t,r){n.insert(e,t,r)},merge:function(e,t,r){n.merge(e,t,r)},empty:function(e){n.empty(e)},switch:function(e,t,r){n.switch(e,t,r)},move:function(e,t,r){n.move(e,t,r)},clipboard:function(e,t,r){n.clipboard(e,t,r)},paste:function(e,t,r){n.paste(e,t,r)},toggleBold:function(e){n.toggleBold(e)},toggleEmphasis:function(e){n.toggleEmphasis(e)}}))}return u(e,[{key:"add",value:function(e,t){return this.enable(e,t),this}},{key:"remove",value:function(e){var t=k(e,this.win.document);this.disable(t);var n,r=Ei(t);try{for(r.s();!(n=r.n()).done;)n.value.classList.remove(c.editableDisabledClass)}catch(e){r.e(e)}finally{r.f()}return this}},{key:"disable",value:function(e){var t,n,r=Ei(k(e||".".concat(c.editableClass),this.win.document));try{for(r.s();!(t=r.n()).done;)(n=t.value).removeAttribute("contenteditable"),n.removeAttribute("spellcheck"),n.removeAttribute("data-plaintext"),function(e,t){if(e.hasAttribute("data-editable")){var n=e.getAttribute("data-editable");et[n]=void 0}}(n),n.classList.remove(c.editableClass),n.classList.add(c.editableDisabledClass)}catch(e){r.e(e)}finally{r.f()}return this}},{key:"enable",value:function(e,t){var n,r=null!=t?t:{},i=r.normalize,o=void 0===i?"boolean"==typeof t&&t:i,a=r.plainText,s=void 0!==a&&a,u=this.config.browserSpellcheck,l=Ei(k(e||".".concat(c.editableDisabledClass),this.win.document));try{for(l.s();!(n=l.n()).done;){var f=n.value;rt(f,{normalize:o,plainText:s,shouldSpellcheck:u}),this.dispatcher.notify("init",f)}}catch(e){l.e(e)}finally{l.f()}return this}},{key:"suspend",value:function(e){var t,n=Ei(k(e||".".concat(c.editableClass),this.win.document));try{for(n.s();!(t=n.n()).done;)t.value.removeAttribute("contenteditable")}catch(e){n.e(e)}finally{n.f()}return this.dispatcher.suspend(),this}},{key:"continue",value:function(e){var t,n=Ei(k(e||".".concat(c.editableClass),this.win.document));try{for(n.s();!(t=n.n()).done;)t.value.setAttribute("contenteditable",!0)}catch(e){n.e(e)}finally{n.f()}return this.dispatcher.continue(),this}},{key:"createCursor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"beginning",n=Wt.findHost(e,this.editableSelector);if(n){var r=A();return"beginning"===t||"end"===t?(r.selectNodeContents(e),r.collapse("beginning"===t)):e!==n?"before"===t?(r.setStartBefore(e),r.setEndBefore(e)):"after"===t&&(r.setStartAfter(e),r.setEndAfter(e)):l("EditableJS: cannot create cursor outside of an editable block."),new Wt(n,r)}}},{key:"createCursorAtCharacterOffset",value:function(e){var t=e.element,n=e.offset,r=Ci({textNodes:ki(t),absOffset:n}),i=r.node,o=r.relativeOffset,a=A();a.setStart(i,o),a.collapse(!0);var s=Wt.findHost(t,this.editableSelector),u=new Wt(s,a);return u.setVisibleSelection(),u}},{key:"createCursorAtBeginning",value:function(e){return this.createCursor(e,"beginning")}},{key:"createCursorAtEnd",value:function(e){return this.createCursor(e,"end")}},{key:"createCursorBefore",value:function(e){return this.createCursor(e,"before")}},{key:"createCursorAfter",value:function(e){return this.createCursor(e,"after")}},{key:"getContent",value:function(e){return be(e)}},{key:"appendTo",value:function(e,t){var n=we(e,this.win.document),r=this.createCursor(n,"end");return r.insertAfter("string"==typeof t?Ce(t):t),r}},{key:"prependTo",value:function(e,t){var n=we(e,this.win.document),r=this.createCursor(n,"beginning");return r.insertBefore("string"==typeof t?Ce(t):t),r}},{key:"getSelection",value:function(e){var t=this.dispatcher.selectionWatcher.getFreshSelection();if(!e||!t)return t;var n=t.range;return null!=e&&e.isConnected&&function(e,t){var n=document.createRange();n.selectNodeContents(e);var r=t.compareBoundaryPoints(Range.START_TO_START,n),i=t.compareBoundaryPoints(Range.END_TO_END,n);return r>=0&&i<=0}(e,n)?t:void 0}},{key:"setupHighlighting",value:function(e){return this.highlighting=new mi(this,e),this}},{key:"setupSpellcheck",value:function(e){var t,n=this;e.markerNode&&(t=e.markerNode.outerHTML),this.setupHighlighting({throttle:e.throttle,spellcheck:{marker:t,spellcheckService:e.spellcheckService}}),this.spellcheck={checkSpelling:function(e){n.highlighting.highlight(e)}}}},{key:"highlight",value:function(e){var t=e.editableHost,n=e.text,r=e.highlightId,i=e.textRange,o=e.raiseEvents,a=e.type,s=void 0===a?"comment":a;return i?"number"!=typeof i.start||"number"!=typeof i.end?(l("Error in Editable.highlight: You passed a textRange object with invalid keys. Expected shape: { start: Number, end: Number }"),-1):i.start===i.end?(l("Error in Editable.highlight: You passed a textRange object with equal start and end offsets, which is considered a cursor and therefore unfit to create a highlight."),-1):rn.highlightRange(t,n,r,i.start,i.end,o?this.dispatcher:void 0,s):rn.highlightText(t,n,r,s)}},{key:"getHighlightPositions",value:function(e){var t=e.editableHost,n=e.type;return rn.extractHighlightedRanges(t,n)}},{key:"removeHighlight",value:function(e){var t=e.editableHost,n=e.highlightId,r=e.raiseEvents;rn.removeHighlight(t,n,r?this.dispatcher:void 0)}},{key:"decorateHighlight",value:function(e){var t=e.editableHost,n=e.highlightId,r=e.addCssClass,i=e.removeCssClass;rn.updateHighlight(t,n,r,i)}},{key:"on",value:function(e,t){return this.dispatcher.on(e,t),this}},{key:"off",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.dispatcher.off.apply(this.dispatcher,t),this}},{key:"unload",value:function(){return this.dispatcher.unload(),this}},{key:"findClosestCursorOffset",value:function(e){var t=e.element,n=e.origCoordinates,r=e.requiredOnFirstLine,i=void 0!==r&&r,o=e.requiredOnLastLine;return function(e){var t=e.host,n=e.requiredOnFirstLine,r=e.requiredOnLastLine,i=e.positionX,o=t.ownerDocument.createRange();o.selectNodeContents(t);var a=o.getBoundingClientRect(),s=ki(t).reduce((function(e,t){return e+t.textContent.length}),0),u=ki(t);if(0===s)return{wasFound:!1};for(var c,l={currentOffset:Math.floor(s/2),leftLimit:0,rightLimit:s},f=l.currentOffset,h=20;l.leftLimit<l.rightLimit&&h>0;){h=h-=1,f=l.currentOffset;var d=Ai({textNodes:u,offset:l.currentOffset}).getBoundingClientRect();c=Math.abs(d.left-i),n&&a.top!==d.top?wi(l):r&&a.bottom!==d.bottom?Si(l):i<d.left?wi(l):Si(l)}var g=Ai({textNodes:u,offset:l.currentOffset}).getBoundingClientRect(),v=Math.abs(g.left-i);return v<c&&(c=v,f=l.currentOffset),{distance:c,offset:f,wasFound:!0}}({host:t,requiredOnFirstLine:i,requiredOnLastLine:void 0!==o&&o,positionX:this.dispatcher.switchContext?this.dispatcher.switchContext.positionX:n.left})}}],[{key:"getGlobalConfig",value:function(){return c}},{key:"globalConfig",value:function(e){Object.assign(c,e),Rt(c)}}]),e}();return xi.parser=n,xi.content=r,["focus","blur","flow","selection","cursor","newline","insert","split","merge","empty","change","switch","move","clipboard","paste","spellcheckUpdated","selectToBoundary"].forEach((function(e){xi.prototype[e]=function(t){return this.on(e,t)}})),t.Editable})()));
|
|
2
2
|
//# sourceMappingURL=editable.js.map
|