@livingdocs/editable.js 5.2.0 → 5.3.0

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 CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Editable=e():t.Editable=e()}(self,()=>(()=>{"use strict";const t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let e={};t.d(e,{Editable:()=>Ho});var n={};t.r(n),t.d(n,{getHost:()=>I,getNodeIndex:()=>P,isBeginningOfHost:()=>W,isDocumentFragmentWithoutChildren:()=>Y,isEndOfHost:()=>q,isEndOffset:()=>$,isInlineElement:()=>J,isLinebreak:()=>D,isSameNode:()=>Q,isStartOffset:()=>U,isTextEndOfHost:()=>z,isTextEndOffset:()=>K,isVoid:()=>L,isVoidTextNode:()=>H,isWhitespaceOnly:()=>F,lastChild:()=>X,lastOffsetWithContent:()=>V,latestChild:()=>G});var r={};t.r(r),t.d(r,{adoptElement:()=>qt,areSameAttributes:()=>Yt,cleanInternals:()=>Ft,cloneRangeContents:()=>Ut,containsString:()=>ye,createFragmentFromString:()=>Wt,deleteCharacter:()=>ge,expandTo:()=>ie,extractContent:()=>Dt,forceWrap:()=>se,getAncestorTags:()=>Qt,getContainedTags:()=>Zt,getInnerHtmlOfFragment:()=>Vt,getInnerTags:()=>Jt,getTagNames:()=>te,getTags:()=>Kt,getTagsByName:()=>Xt,getTagsByNameAndAttributes:()=>Gt,insertCharacter:()=>ve,isAffectedBy:()=>ee,isExactSelection:()=>re,isWrappable:()=>ae,normalizeTags:()=>Lt,normalizeWhitespace:()=>Ht,nuke:()=>he,nukeElem:()=>de,nukeTag:()=>me,removeFormatting:()=>fe,removeFormattingElem:()=>le,selectNodeContents:()=>ne,surround:()=>pe,tidyHtml:()=>Pt,toggleTag:()=>oe,unwrap:()=>ce,unwrapInternalNodes:()=>zt,wrap:()=>ue});const i={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 o(){if(!1!==i.logErrors){var e=1===arguments.length?arguments[0]:Array.from(arguments);if(t.g.console)return"function"==typeof console.error?console.error(e):void console.log(e)}}var a=Object.prototype.toString,s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function u(t){return t.replace(/\s+$/,"")}function c(t){return t.replace(/^\s+|\s+$/g,"")}function l(t){return"[object String]"===a.call(t)}var f=1,h=3,d=11;function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function p(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,g(r.key),r)}}function g(t){var e=function(t){if("object"!=v(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==v(e)?e:e+""}var y=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.current=this.previous=this.nextNode=this.root=e,this.iteratorFunc=this[n||"getNext"]},(e=[{key:Symbol.iterator,value:function(){return this}},{key:"getNextTextNode",value:function(){for(var t;t=this.getNext();)if(t.nodeType===h&&""!==t.data)return t}},{key:"getPreviousTextNode",value:function(){for(var t;t=this.getPrevious();)if(t.nodeType===h&&""!==t.data)return t}},{key:"next",value:function(){var t=this.iteratorFunc();return t?{value:t}:{done:!0}}},{key:"getNext",value:function(){var t=this.current=this.nextNode,e=this.nextNode=void 0;if(this.current)if((e=t.firstChild)&&"remove"!==t.getAttribute("data-editable"))this.nextNode=e;else for(;t!==this.root&&!(this.nextNode=t.nextSibling);)t=t.parentNode;return this.current}},{key:"getPrevious",value:function(){var t=this.current=this.previous,e=this.previous=void 0;if(this.current)if((e=t.lastChild)&&"remove"!==t.getAttribute("data-editable"))this.previous=e;else for(;t!==this.root&&!(this.previous=t.previousSibling);)t=t.parentNode;return this.current}},{key:"replaceCurrent",value:function(t){this.current=t,this.nextNode=void 0,this.previous=void 0;for(var e=this.current;e!==this.root&&!(this.nextNode=e.nextSibling);)e=e.parentNode}}])&&p(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),m=function(t,e){return"string"==typeof t?Array.from(e.querySelectorAll(t)):t.tagName?[t]:Array.isArray(t)?t:Array.from(t)},b=function(t,e){return"string"==typeof t?e.querySelector(t):t.tagName?t:t[0]?t[0]:t},w=function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return e.innerHTML=t,e.firstElementChild},S=function(t,e){if(t.closest||(t=t.parentNode),t&&t.closest)return t.closest(e)},k=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).document.createRange()},C=function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:window).document.getSelection()},A=function(t,e,n){for(var r,i=[],o=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:window).document.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_ALL,{acceptNode:function(r){return t.intersectsNode(r)&&e.includes(r.nodeType)&&r!==t.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},E=function(t){t.startContainer.compareDocumentPosition(t.endContainer)===Node.DOCUMENT_POSITION_FOLLOWING&&t.setStartBefore(t.endContainer),t.endContainer.compareDocumentPosition(t.startContainer)===Node.DOCUMENT_POSITION_PRECEDING&&t.setEndAfter(t.startContainer)},T=function(t,e){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},x=function(t){return t&&(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.COMMENT_NODE)},O=function(t,e){return t.splitText(e)},N=function(t){var e=t.startContainer,n=t.startOffset,r=t.endContainer,i=t.endOffset;if(x(r)&&i>0&&i<r.length&&O(r,i),x(e)&&n>0&&n<e.length){var o=O(e,n);t.setStart(o,0)}},j=function(t,e){var n=t.cloneRange();n.setStart(e,0),n.setEnd(t.startContainer,t.startOffset);var r=t.toString().replace(/\uFEFF/g,""),i=n.toString().length;return{start:i,end:i+r.length,text:r}},_=function(t,e){return t.startContainer===e.startContainer&&t.startOffset===e.startOffset&&t.endContainer===e.endContainer&&t.endOffset===e.endOffset};function R(t){var e=t.root,n=t.startContainer,r=t.startOffset,i=t.whitespacesOnTheLeft;if(n.nodeType!==h)return R({root:e,startContainer:n.childNodes[r],startOffset:0,whitespacesOnTheLeft:i});var o=r+i;if(n.length>o)return[n,o];var a=new y(e);a.nextNode=n,a.getNextTextNode();var s=a.getNextTextNode();if(!s){var u=a.getPreviousTextNode();return[u,u.length]}return R({root:e,startContainer:s,startOffset:0,whitespacesOnTheLeft:o-n.length})}function B(t){var e=t.root,n=t.endContainer,r=t.endOffset,i=t.whitespacesOnTheRight;if(n.nodeType!==h){var o=!n.childNodes[r-1],a=o?n.childNodes[r]:n.childNodes[r-1],s=0;return o||(s=a.nodeType===h?a.length:a.childNodes.length),B({root:e,endContainer:a,endOffset:s,whitespacesOnTheRight:i})}var u=r-i;if(u>0)return[n,u];var c=new y(e);c.previous=n,c.getPreviousTextNode();var l=c.getPreviousTextNode();return l?B({root:e,endContainer:l,endOffset:l.length,whitespacesOnTheRight:i-r}):[c.getNextTextNode(),0]}function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function I(t){return t=t.jquery?t[0]:t,S(t,".".concat(i.editableClass))}function P(t){for(var e=0;null!==(t=t.previousSibling);)e++;return e}function L(t){var e,n=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return M(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?M(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},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(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(t.childNodes);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(r.nodeType===h&&!H(r))return!1;if(r.nodeType===f)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}function H(t){return t.nodeType===h&&!t.nodeValue}function F(t){return t.nodeType===h&&0===V(t)}function D(t){return t.nodeType===f&&"BR"===t.tagName}function V(t){if(t.nodeType===h)return u(t.nodeValue).length;var e=0;return Array.from(t.childNodes).reverse().every(function(t,n,r){return!(!F(t)&&!D(t)&&(e=r.length-n,1))}),e}function W(t,e,n){if(e===t)return U(e,n);if(U(e,n)){var r=P(e);return W(t,e.parentNode,r)}return!1}function q(t,e,n){if(e===t)return $(e,n);if($(e,n)){var r=P(e)+1;return q(t,e.parentNode,r)}return!1}function U(t,e){return t.nodeType===h?0===e:0===t.childNodes.length||1===t.childNodes.length&&t.firstChild.nodeType===f&&"remove"===t.firstChild.getAttribute("data-editable")||t.childNodes[e]===t.firstChild}function $(t,e){return t.nodeType===h?e===t.length:0===t.childNodes.length||e>0&&t.childNodes[e-1]===t.lastChild}function z(t,e,n){if(e===t)return K(e,n);if(K(e,n)){var r=P(e)+1;return z(t,e.parentNode,r)}return!1}function K(t,e){return t.nodeType===h?e>=u(t.nodeValue).length:0===t.childNodes.length||e>=V(t)}function Q(t,e){var n,r,i;if(t.nodeType!==e.nodeType)return!1;if(t.nodeName!==e.nodeName)return!1;for(n=0,r=t.attributes.length;n<r;n++)if(i=t.attributes[n],e.getAttribute(i.name)!==i.value)return!1;return!0}function X(t){return t.lastChild?X(t.lastChild):t}function G(t){return console.warn("Editable.js: Using obsolete function parser.latestCild(), use lastChild() instead"),X(t)}function Y(t){return t&&t.nodeType===d&&0===t.childNodes.length}function J(t,e){switch((e.currentStyle||t.getComputedStyle(e,"")).display){case"inline":case"inline-block":return!0;default:return!1}}var Z=0,tt="\ufeff";function et(t,e){var n=t.commonAncestorContainer;if(3===n.nodeType)return!1;var r=e.parentElement;return(null==r?void 0:r.parentElement)===n}function nt(t,e){var n=t.commonAncestorContainer;n.ownerDocument||o("Cannot save range: range is empty");var r=n.ownerDocument.defaultView.document,i=r.createElement("span");i.id="editable-range-boundary-".concat(++Z),i.setAttribute("data-editable","remove"),i.style.lineHeight="0",i.style.display="none",i.appendChild(r.createTextNode(tt));var a=e&&et(t,t.startContainer),s=!e&&et(t,t.endContainer);if(a){var u=t.startContainer.parentElement;u.parentElement.insertBefore(i,u)}else if(s){var c=t.endContainer.parentElement;c.parentElement.insertBefore(i,c.nextSibling)}else{var l=t.cloneRange();l.collapse(e),l.insertNode(i)}return i}function rt(t,e,n,r){var i=at(t,n);if(!i)return console.log("Marker element has been removed. Cannot restore selection.");e[r?"setStartBefore":"setEndBefore"](i),i.remove()}function it(t){var e,n,r;return t.collapsed?e={markerId:(r=nt(t,!1)).id,collapsed:!0}:(r=nt(t,!1),e={startMarkerId:(n=nt(t,!0)).id,endMarkerId:r.id,collapsed:!1}),t.collapsed?(t.setStartBefore(r),t.collapse(!0)):(t.setEndBefore(r),t.setStartAfter(n)),e}function ot(t,e){if(!e.restored){var n=k();if(e.collapsed){var r=at(t,e.markerId);if(r){r.style.display="inline";var i=r.previousSibling;i&&i.nodeType===h?(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 rt(t,n,e.startMarkerId,!0),rt(t,n,e.endMarkerId,!1);return E(n),n}}function at(t,e){return t.querySelector("#".concat(e))}function st(t){return{x:void 0!==t.pageXOffset?t.pageXOffset:(t.document.documentElement||t.document.body.parentNode||t.document.body).scrollLeft,y:void 0!==t.pageYOffset?t.pageYOffset:(t.document.documentElement||t.document.body.parentNode||t.document.body).scrollTop}}function ut(t,e){return ut=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ut(t,e)}function ct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ct=function(){return!!t})()}function lt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||ht(t,e)||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 ft(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=ht(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},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(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function ht(t,e){if(t){if("string"==typeof t)return dt(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?dt(t,e):void 0}}function dt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var vt=new WeakMap,pt=/[\uFEFF\u200B]/g,gt=function(t){return"\ufeff"===t||"​"===t},yt=function(t){return t.indexOf("\ufeff")>=0||t.indexOf("​")>=0},mt=function(t){return yt(t)?t.replace(pt,""):t};function bt(t){var e,n=t.editableHost,r=t.win,i=void 0===r?null==n||null===(e=n.ownerDocument)||void 0===e?void 0:e.defaultView:r,o=vt.get(i);if(null!=o&&o.size){var a,s=ft(o);try{for(s.s();!(a=s.n()).done;){var u=lt(a.value,2),c=u[0],l=u[1];if(l.has(n)){var f,h=ft(l.keys());try{for(h.s();!(f=h.n()).done;){var d=f.value;null!=d&&d.isConnected||l.delete(d)}}catch(t){h.e(t)}finally{h.f()}l.size?kt({name:c,hosts:l,win:i}):St({name:c,win:i})}}}catch(t){s.e(t)}finally{s.f()}}}function wt(t){var e=t.editableHost,n=t.start,r=t.end,i=t.win,o=void 0===i?window:i;return At({segments:Ct(e).segments,start:n,end:r,win:o})}function St(t){var e,n=t.name,r=t.win,i=void 0===r?window:r;null===(e=vt.get(i))||void 0===e||e.delete(n),i.CSS.highlights.delete(n)}function kt(t){var e,n=t.name,r=t.hosts,i=t.win,o=[],a=ft(r);try{for(a.s();!(e=a.n()).done;){var s=lt(e.value,2),u=s[0],c=s[1],l=Ct(u).segments;if(l.length){var f,h=ft(c);try{for(h.s();!(f=h.n()).done;){var d=f.value,v=At({segments:l,start:d.start,end:d.end,win:i});v&&o.push(v)}}catch(t){h.e(t)}finally{h.f()}}}}catch(t){a.e(t)}finally{a.f()}if(!o.length)return i.CSS.highlights.delete(n);i.CSS.highlights.set(n,function(t,e,n){if(ct())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&ut(i,n.prototype),i}(i.Highlight,o))}function Ct(t){var e,n=[],r="",i=function(t,e,i){n.push({node:t,nodeOffset:e,start:r.length,end:r.length+i.length}),r+=i},o=ft(new y(t));try{for(o.s();!(e=o.n()).done;){var a=e.value;if(a.nodeType!==f||"BR"!==a.nodeName){if(a.nodeType===h&&""!==a.data){var s=a.data;if(yt(s)){for(var u=0,c=0,l=0;l<s.length;l++)gt(s[l])?(c&&i(a,u,s.slice(u,u+c)),c=0):(0===c&&(u=l),c+=1);c&&i(a,u,s.slice(u,u+c))}else i(a,0,s)}}else r+="\n"}}catch(t){o.e(t)}finally{o.f()}for(var d=r.length-r.trimStart().length,v=r.trimEnd().length,p=[],g=0,m=n;g<m.length;g++){var b=m[g],w=Math.max(b.start,d),S=Math.min(b.end,v);w>=S||p.push({node:b.node,nodeOffset:b.nodeOffset+(w-b.start),start:w-d,end:S-d})}return{text:r.slice(d,Math.max(d,v)),leading:d,segments:p}}function At(t){var e=t.segments,n=t.start,r=t.end,i=t.win,o=Et(e,n,!1),a=Et(e,r,!0);if(o&&a){var s=k(i);return s.setStart(o.node,o.offset),s.setEnd(a.node,a.offset),s}}function Et(t,e,n){for(var r=0,i=t.length;r<i;){var o=r+i>>1,a=t[o].end;(n?a>=e:a>e)?i=o:r=o+1}var s=t[r];if(s)return{node:s.node,offset:s.nodeOffset+Math.max(0,e-s.start)}}function Tt(t,e,n){return{top:t.top+n,bottom:t.bottom+n,left:t.left+e,right:t.right+e,width:t.width,height:t.height}}function xt(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Ot(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ot(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},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(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Ot(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Nt(t,e,n){return e=it(e),n(),ot(t,e)}var jt=/\u200B/g,_t=/\uFEFF/g,Rt=/[^\S ]/g,Bt=/^\s+$/,Mt=/^\s+/,It=/\s+$/;function Pt(t){Lt(t)}function Lt(t){var e=document.createDocumentFragment();$t(t,"firstChild"),$t(t,"lastChild");var n,r=xt(t.childNodes);try{for(r.s();!(n=r.n()).done;){var i=n.value;if("BR"===i.nodeName||i.textContent){if(i.nodeType===f&&"BR"!==i.nodeName){for(var o=i;null!==(o=o.nextSibling)&&Q(o,i);){var a,s=xt(o.childNodes);try{for(s.s();!(a=s.n()).done;){var u=a.value;i.appendChild(u.cloneNode(!0))}}catch(t){s.e(t)}finally{s.f()}o.remove()}Lt(i)}e.appendChild(i.cloneNode(!0))}}}catch(t){r.e(t)}finally{r.f()}for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(e)}function Ht(t){return t.replace(Rt," ")}function Ft(t){t.innerHTML=Dt(t,!0),bt({editableHost:t})}function Dt(t,e){var n=(t.nodeType===d?Vt(t):t.innerHTML).replace(_t,"").replace(jt,""),r=document.createElement("div");return r.innerHTML=n,zt(r,e),$t(r,"firstChild"),$t(r,"lastChild"),r.innerHTML}function Vt(t){var e=t.cloneNode(!0),n=document.createElement("div");return n.appendChild(e),n.innerHTML}function Wt(t){var e=document.createElement("div");e.innerHTML=t;for(var n=document.createDocumentFragment();e.firstChild;)n.appendChild(e.firstChild);return n}function qt(t,e){return t.ownerDocument!==e?e.adoptNode(t):t}function Ut(t){for(var e=t.cloneContents().childNodes[0],n=document.createDocumentFragment();e.childNodes.length;)n.appendChild(e.childNodes[0]);return n}function $t(t,e){for(var n,r,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];r=t[e];)if(r.nodeType===h){if(!Bt.test(r.textContent))break;t.removeChild(r)}else{if("BR"!==r.nodeName){r[e]&&$t(r,e,!1);break}r.remove()}o&&(null===(n=r=t[e])||void 0===n?void 0:n.nodeType)===h&&i.trimLeadingAndTrailingWhitespaces&&(r.textContent=r.textContent.replace(e.startsWith("last")?It:Mt,""))}function zt(t,e){for(;t;){var n=t.nextSibling;if(t.nodeType===f){var r=t.getAttribute("data-editable");t.firstChild&&zt(t.firstChild,e),("remove"===r||"ui-remove"===r&&!e)&&t.remove(),("unwrap"===r||"ui-unwrap"===r&&!e)&&ce(t),t=n}else t=n}}function Kt(t,e,n){var r=Jt(e,n),i=Qt(t,e,n);return r.concat(i)}function Qt(t,e,n){for(var r=[],i=e.commonAncestorContainer;i!==t;)n&&!n(i)||r.push(i),i=i.parentNode;return r}function Xt(t,e,n){return Kt(t,e,function(t){return t.nodeName.toUpperCase()===n.toUpperCase()})}function Gt(t,e,n){return Kt(t,e,function(t){return t.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&Yt(t.attributes,n.attributes)})}function Yt(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++){var r=e[t[n].name];if(!r||r.value!==t[n].value)return!1}return!0}function Jt(t,e){return A(t,[f],e)}function Zt(t,e){return A(t,[f],e).filter(function(e){return T(t,e)})}function te(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return t.nodeName})}function ee(t,e,n){return Kt(t,e).some(function(t){return t.nodeName===n.toUpperCase()})}function ne(t){var e=k();return e.selectNodeContents(t),e}function re(t,e,n){var r,i,o=k();if(o.selectNodeContents(e),i=o,-1!==(r=t).compareBoundaryPoints(Range.END_TO_START,i)||-1!==i.compareBoundaryPoints(Range.END_TO_START,r))return!1;var a=t.toString(),s=(e.jquery?e[0]:e).textContent;return n&&(a=c(a),s=c(s)),""!==a&&a===s}function ie(t,e,n){return e.selectNodeContents(n),e}function oe(t,e,n){var r=Gt(t,e,n);return 1===r.length&&re(e,r[0],"visible")?le(t,e,n):se(t,e,n)}function ae(t){return function(t){if(!t||!t.startContainer||!t.endContainer)return!1;if(t.startContainer===t.endContainer)return!0;for(var e,n=function(t){var e=t,n=null;return{next:function(){if(!e)return null;if(e.firstChild&&n!==e.firstChild)n=e,e=e.firstChild;else if(e.nextSibling)n=e,e=e.nextSibling;else{for(var r=e.parentNode;r&&r!==t;){if(r.nextSibling){n=e=r.nextSibling;break}r=r.parentNode}r&&r!==t||(n=e=null)}return e}}}(t.commonAncestorContainer),r=!1;e=n.next();)if(e.nodeType===Node.ELEMENT_NODE&&!be(e,t)){r=!0;break}return!r}(t)}function se(t,e,n){var r=Nt(t,e,function(){de(t,e,n)});return ae(r)||(r=Nt(t,r,function(){he(t,r)})),ue(r,n),bt({editableHost:t}),r}function ue(t,e){ae(t)?("string"==typeof e&&(e=w(e)),t.surroundContents(e)):console.log("content.wrap(): can not surround range")}function ce(t){for(var e=(t=t.jquery?t[0]:t).parentNode;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}function le(t,e,n){var r=Nt(t,e,function(){de(t,e,n)});return bt({editableHost:t}),r}function fe(t,e,n){var r=Nt(t,e,function(){he(t,e,n)});return bt({editableHost:t}),r}function he(t,e,n){Kt(t,e).forEach(function(t){"BR"===t.nodeName.toUpperCase()||n&&!t.matches(n)||ce(t)})}function de(t,e,n){Kt(t,e).forEach(function(t){"BR"!==t.nodeName.toUpperCase()&&(!n||t.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&Yt(t.attributes,n.attributes))&&ce(t)})}function ve(t,e,n){var r=document.createTextNode(e),i=t.cloneRange();i.collapse(n),i.insertNode(r),t[n?"setStartBefore":"setEndAfter"](r),E(t)}function pe(t,e,n,r){return ve(e,r||n,!1),ve(e,n,!0),e}function ge(t,e,n){if(!ye(e,n))return e;window.getSelection().rangeCount>0&&N(e);var r=Nt(t,e,function(){A(e,[h],function(t){return t.nodeValue.indexOf(n)>=0}).forEach(function(t){t.nodeValue=t.nodeValue.replaceAll(n,"")})});return E(r),r}function ye(t,e){return t.toString().indexOf(e)>=0}function me(t,e,n){Kt(t,e).forEach(function(t){t.nodeName.toUpperCase()===n.toUpperCase()&&ce(t)})}function be(t,e){var n=document.createRange();return n.selectNodeContents(t),e.compareBoundaryPoints(Range.START_TO_START,n)<=0&&e.compareBoundaryPoints(Range.END_TO_END,n)>=0}var we=1,Se={},ke=xe("nextElementSibling"),Ce=xe("previousElementSibling");function Ae(t,e){var n=e.normalize,r=e.plainText,o=e.shouldSpellcheck;!function(t){t.hasAttribute("data-editable")||(t.setAttribute("data-editable","id-".concat(we)),we+=1)}(t),t.setAttribute("contenteditable",!0),t.setAttribute("spellcheck",Boolean(o)),t.setAttribute("data-plaintext",Boolean(r)),t.classList.remove(i.editableDisabledClass),t.classList.add(i.editableClass),n&&Pt(t)}function Ee(t){t.removeAttribute("contenteditable"),t.removeAttribute("spellcheck"),t.removeAttribute("data-plaintext"),function(t){if(t.hasAttribute("data-editable")){var e=t.getAttribute("data-editable");Se[e]=void 0}}(t),t.classList.remove(i.editableClass),t.classList.add(i.editableDisabledClass)}function Te(t){return"true"===t.getAttribute("data-plaintext")}function xe(t){return function(e){var n=e[t];return n&&n.getAttribute("contenteditable")?n:null}}function Oe(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var Ne,je,_e,Re,Be,Me,Ie,Pe,Le,He=[["«","»"],["»","«"],['"','"'],["“","”"],["”","”"],["“","“"],["„","“"]],Fe=[["‘","’"],["‹","›"],["‚","‘"],["’","’"],["›","‹"],["'","'"],["‘","’"]],De=["’","'"],Ve=/([‘’‹›‚'«»"“”„])(?![^<]*?>)/g,We=/\s|[>\-–—«»”"“„]/,qe=/\s|[<\-–—«»”"“‘’‹›'.;?:,]/;function Ue(t,e){(Ne=e||{}).quotes=Ne.quotes||[void 0,void 0],Ne.singleQuotes=Ne.singleQuotes||[void 0,void 0];var n=function(t){return(e=t.matchAll(Ve),function(t){if(Array.isArray(t))return Oe(t)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return Oe(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Oe(t,e):void 0}}(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.")}()).map(function(e){var n=e.index;return{char:e[1],before:n>0?t[n-1]:"",after:n+1<t.length?t[n+1]:""}});var e}(t);return n.length>0?($e(n,0),function(t,e){var n=0;return t.replace(Ve,function(t){var r=e[n].replace||e[n].char;return n+=1,r})}(t,n)):t}function $e(t,e){for(;e<t.length;){var n=ze(t,e);if(n){if(t[e].replace="double"===n.type?Ne.quotes[0]:Ne.singleQuotes[0],t[n.position].replace="double"===n.type?Ne.quotes[1]:Ne.singleQuotes[1],n.position!==e+1){var r=t.slice(e+1,n.position);r&&$e(r,0)}e=n.position+1}else t[e].replace=Qe(t[e].char),e+=1}}function ze(t,e){if(e!==t.length-1){var n=t[e],r=n.char;if(!n.before||We.test(n.before))for(var i=Ke(r,Fe),o=Ke(r,He),a=e+1;a<t.length;a++)if(t[a].after&&qe.test(t[a].after)||!t[a].after){if(i.includes(t[a].char))return{position:a,type:"single"};if(o.includes(t[a].char))return{position:a,type:"double"}}}}function Ke(t,e){return e.filter(function(e){return e[0]===t}).map(function(t){return t[1]})}function Qe(t){if(De.includes(t))return Ne.apostrophe}var Xe,Ge=/^\s*$/,Ye="\x3c!-- BLOCK --\x3e";function Je(t){var e=t.pastedHtmlRules;je=e.allowedElements||{},_e=e.allowedPlainTextElements||{},Re=e.requiredAttributes||{},Be=e.transformElements||{},Le=e.blacklistedElements||[],Xe=e.keepInternalRelativeLinks||!1,Ie=e.replaceQuotes||{},Me={},e.blockLevelElements.forEach(function(t){Me[t]=!0}),Pe={},e.splitIntoBlocks.forEach(function(t){Pe[t]=!0})}function Ze(t,e,n){var r=t.ownerDocument;t.setAttribute(i.pastingAttribute,!0),e.isSelection&&(e=e.deleteExactSurroundingTags().deleteContainedTags().deleteContent());var o=r.createElement("div");o.innerHTML=n;var a=function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).plainText,n=void 0!==e&&e;return tn(t,{allowedElements:n?_e:je,keepInternalRelativeLinks:!n&&Xe}).split(Ye).map(function(t){return c((e=t,Ie.quotes||Ie.singleQuotes||Ie.apostrophe?Ue(e,Ie):e).replace(/\n/g," ").replace(/ {2,}/g," ").replace(/(.)\u00A0/g,function(t,e){return e+(/[\u0020]/.test(e)?" ":" ")}));var e}).filter(function(t){return!Ge.test(t)})}(o,{plainText:Te(t)});return t.removeAttribute(i.pastingAttribute),{blocks:a,cursor:e}}function tn(t,e){return Array.from(t.childNodes).reduce(function(t,n){if(-1!==Le.indexOf(n.nodeName.toLowerCase()))return"";if(e.keepInternalRelativeLinks&&"A"===n.nodeName&&n.href){var r=n.getAttribute("href").replace(window.location.origin,"");n.setAttribute("href",r)}return n.nodeType===f?t+function(t,e,n){var r=t.nodeName.toLowerCase();if(function(t,e,n){return n.allowedElements[t]&&function(t,e){var n=Re[t];return!n||!n.some(function(t){return!e.getAttribute(t)})}(t,e)}(r=function(t){return Be[t]||t}(r),t,n)){var i=function(t,e){return Array.from(e.attributes).reduce(function(e,n){var r,i=n.name,o=n.value;return null!==(r=je[t])&&void 0!==r&&r[i]&&o?"".concat(e," ").concat(i,'="').concat(o,'"'):e},"")}(r,t);return"br"===r?"<".concat(r+i,">"):Ge.test(e)?e:"<".concat(r+i,">").concat(e,"</").concat(r,">")}return Pe[r]?Ye+e+Ye:Me[r]?"".concat(e," "):e}(n,tn(n,e),e):n.nodeType===h?t+n.nodeValue.replace(/[&<>]/g,function(t){return s[t]}):t},"")}Je(i),document.documentElement.contentEditable;var en=/(apple)?webkit\/537\.36/i.test(window.navigator.userAgent),nn=/(apple)?webkit/i.test(window.navigator.userAgent),rn=!en&&nn,on=function(t){var e=t,n=e.onselectionchange;if(void 0!==n)try{return e.onselectionchange=0,null===e.onselectionchange}catch(t){}finally{e.onselectionchange=n}return!1}(document),an=!!rn;function sn(t,e){var n=function(t){var e={};function n(t,n){t.split(" ").forEach(function(t){e[t]=e[t]||[],e[t].unshift(n)})}return{on:function(t,e){if(2===arguments.length)n(t,e);else if(1===arguments.length)for(var r in t)n(r,t[r]);return this},off:function(t,n){2===arguments.length?function(t,n){var r=e[t];if(r){var i=r.indexOf(n);i<0||r.splice(i,1)}}(t,n):1===arguments.length?e[t]=[]:e={}},notify:function(n,r){var i=Array.from(arguments);t?(r=n,n=t,i.splice(0,1)):i.splice(0,2),this.switchContext&&r!==this.switchContext.events.shift()&&(this.switchContext=void 0);var o=e[r];o&&o.every(function(t){return!1!==t.apply(n,i)})}}}(e);t.on=n.on,t.off=n.off,t.notify=n.notify}function un(t){return un="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},un(t)}function cn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ln(r.key),r)}}function ln(t){var e=function(t){if("object"!=un(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=un(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==un(e)?e:e+""}var fn=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.setHost(e),this.range=n,this.isCursor=!0}return e=t,n=[{key:"getTags",value:function(t){return Kt(this.host,this.range,t)}},{key:"getTagNames",value:function(t){return te(this.getTags(t))}},{key:"getTagsByName",value:function(t){return Xt(this.host,this.range,t)}},{key:"getInnerTags",value:function(t){return Jt(this.range,t)}},{key:"getContainedTags",value:function(t){return Zt(this.range,t)}},{key:"getAncestorTags",value:function(t){return Qt(this.host,this.range,t)}},{key:"isAtEnd",value:function(){return q(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtTextEnd",value:function(){return z(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtLastLine",value:function(){var t=this.win.document.createRange();t.selectNodeContents(this.host),t.collapse(!1);var e=hn(t,this.win),n=hn(this.range,this.win);return dn(e.bottom,n.bottom)}},{key:"isAtFirstLine",value:function(){var t=this.win.document.createRange();t.selectNodeContents(this.host),t.collapse(!0);var e=hn(t,this.win),n=hn(this.range,this.win);return dn(e.top,n.top)}},{key:"isAtBeginning",value:function(){return W(this.host,this.range.startContainer,this.range.startOffset)}},{key:"insertBefore",value:function(t){if(l(t)&&(t=Wt(t)),!Y(t)){var e=t=this.adoptElement(t);if(t.nodeType===d){var n=t.childNodes.length-1;e=t.childNodes[n]}this.range.insertNode(t),this.range.setStartAfter(e),this.range.setEndAfter(e),this.host.normalize()}}},{key:"insertAfter",value:function(t){if(l(t)&&(t=Wt(t)),!Y(t)){t=this.adoptElement(t);var e=this.range.cloneRange();e.setStart(e.endContainer,e.endOffset),e.collapse(!0),e.insertNode(t),this.host.normalize()}}},{key:"setSelection",value:function(){this.setVisibleSelection()}},{key:"setVisibleSelection",value:function(){if(this.win.document.activeElement!==this.host){var t=st(this.win),e=t.x,n=t.y;this.win.scrollTo(e,n)}var r=C(this.win);r.removeAllRanges(),r.addRange(this.range)}},{key:"before",value:function(){var t=this.range.cloneRange();return t.collapse(!0),t.setStartBefore(this.host),Ut(t)}},{key:"textBefore",value:function(){var t=this.range.cloneRange();return t.collapse(!0),t.setStartBefore(this.host),t.toString()}},{key:"beforeHtml",value:function(){return Vt(this.before())}},{key:"after",value:function(){var t=this.range.cloneRange();return t.collapse(!1),t.setEndAfter(this.host),Ut(t)}},{key:"textAfter",value:function(){var t=this.range.cloneRange();return t.collapse(!1),t.setEndAfter(this.host),t.toString()}},{key:"afterHtml",value:function(){return Vt(this.after())}},{key:"getBoundingClientRect",value:function(){return this.range.getBoundingClientRect()}},{key:"getCoordinates",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"absolute",e=this.range.getBoundingClientRect();if("fixed"===t)return e;var n=st(this.win),r=n.x,i=n.y;return{top:e.top+i,bottom:e.bottom+i,left:e.left+r,right:e.right+r,height:e.height,width:e.width}}},{key:"moveBefore",value:function(e){if(this.updateHost(e),this.range.setStartBefore(e),this.range.setEndBefore(e),this.isSelection)return new t(this.host,this.range)}},{key:"moveAfter",value:function(e){if(this.updateHost(e),this.range.setStartAfter(e),this.range.setEndAfter(e),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtBeginning",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(e),this.range.selectNodeContents(e),this.range.collapse(!0),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtEnd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(e),this.range.selectNodeContents(e),this.range.collapse(!1),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtTextEnd",value:function(t){return this.moveAtEnd(X(t))}},{key:"setHost",value:function(t){t.jquery&&(t=t[0]),this.host=t,this.win=null==t?window:t.ownerDocument.defaultView}},{key:"updateHost",value:function(t){var e=I(t);e||o("Can not set cursor outside of an editable block"),this.setHost(e)}},{key:"retainVisibleSelection",value:function(t){this.save(),t(),this.restore(),this.setVisibleSelection()}},{key:"save",value:function(){this.savedRangeInfo=it(this.range),this.savedRangeInfo.host=this.host}},{key:"restore",value:function(){this.savedRangeInfo||o("Could not restore selection"),this.host=this.savedRangeInfo.host,this.range=ot(this.host,this.savedRangeInfo),this.savedRangeInfo=void 0}},{key:"equals",value:function(t){return!!(t&&t.host&&t.host.isEqualNode(this.host)&&t.range&&_(t.range,this.range))}},{key:"createElement",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.win.document.createElement(t);for(var r in e){var i=e[r];n.setAttribute(r,i)}return n}},{key:"createTextNode",value:function(t){return this.win.document.createTextNode(t)}},{key:"adoptElement",value:function(t){return qt(t,this.win.document)}},{key:"triggerChange",value:function(){var t=new Event("formatEditable",{bubbles:!0,cancelable:!1});this.host.dispatchEvent(t)}}],r=[{key:"findHost",value:function(t,e){return S(t,e)}}],n&&cn(e.prototype,n),r&&cn(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function hn(t,e){if(t.startContainer.nodeType!==f)return t.getBoundingClientRect();var n=e.document.createElement("span");n.setAttribute("doc-editable","unwrap"),t.insertNode(n);var r=n.getBoundingClientRect();return n.remove(),r}function dn(t,e){return t===e||Math.abs(t-e)<=2}const vn={extractText:function(t){var e="";return function(t,e,n){for(var r,i=new y(t);r=i.getNext();)r.nodeType===h&&""!==r.data?n(r.data):e&&r.nodeType===f&&"BR"===r.nodeName&&n("\n")}(t,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],function(t){e+=t}),e},highlightMatches:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e&&0!==e.length){t.normalize();for(var r,i,o,a=new y(t),s=0,u=0,c=e[s],l=[];r=a.getNext();)if(r.nodeType===h&&""!==r.data){var d=(o=r).data,v=u+d.length;if(c.startIndex<v&&u<c.endIndex){var p=u<=c.startIndex,g=v>=c.endIndex;p&&(i=c.id||c.startIndex);var m;m=p?c.startIndex-u:0;var b;b=g?c.endIndex-u-m:d.length-m;var w={element:o,text:d.substring(m,m+b),offset:m,length:b,isLastPortion:g,wordId:i};if(l.push(w),g){var S=this.wrapMatch(l,c.marker,c.title);a.replaceCurrent(S),v=u+w.length+w.offset,l=[],(s+=1)<e.length&&(c=e[s])}}u=v}else if(n&&r.nodeType===f&&"BR"===r.nodeName){u+=1;continue}}},wrapMatch:function(t,e,n){var r=this;return t.map(function(t){return r.wrapPortion(t,e,n)}).pop()},wrapPortion:function(t,e,n){var r=k();r.setStart(t.element,t.offset),r.setEnd(t.element,t.offset+t.length);var i=e.cloneNode(!0);if(i.setAttribute("data-word-id",t.wordId),n&&i.setAttribute("title",n),r.surroundContents(i),i.nextSibling){var o=i.nextSibling;o.nodeType===h&&""===o.data&&o.remove()}return i}};function pn(t){return pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pn(t)}function gn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function yn(t,e,n,r){if(!t||""===t)return[];if(r&&!function(t){try{var e;return!!t&&t instanceof(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView.HTMLElement)}catch(e){return"object"===pn(t)&&1===t.nodeType&&"object"===pn(t.style)&&"object"===pn(t.ownerDocument)}}(r))return[];if(null==e||!e.length)return[];var i,o=("word"===n?wn:mn)(e);return(i=t.matchAll(o),function(t){if(Array.isArray(t))return gn(t)}(i)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(i)||function(t,e){if(t){if("string"==typeof t)return gn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?gn(t,e):void 0}}(i)||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.")}()).map(function(t){var e,i;return"word"===n?(e=t.index+t[1].length,i=t[2]):(e=t.index,i=t[0]),{startIndex:e,endIndex:e+i.length,match:i,marker:r}})}function mn(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return Sn(t)}),e="(".concat(t.join("|"),")");return new RegExp(e,"g")}var bn="\\u0041-\\u005A\\u0061-\\u007A\\u0030-\\u0039\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u00FF\\u0100-\\u017F\\u0180-\\u024F";function wn(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return Sn(t)}),e="([^".concat(bn,"]|^)")+"(".concat(t.join("|"),")")+"(?=[^".concat(bn,"]|$)");return new RegExp(e,"g")}function Sn(t){return String(t).replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function kn(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Cn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Cn(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},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(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Cn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var An={highlightText:function(t,e,n,r,i){if(!this.hasHighlight(t,n)){var o=vn.extractText(t),a='<span class="highlight-'.concat(r,'"></span>'),s=function(t,e,n){return yn(t,[e],"text",n)}(o,e,An.createMarkerNode(a,r,this.win));return s&&s.length?(n&&(s[0].id=n),vn.highlightMatches(t,s),bt({editableHost:t}),i&&i.notify("change",t),s[0].startIndex):void 0}},highlightRange:function(t,e,n,r,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"comment";this.hasHighlight(t,n)&&this.removeHighlight(t,n);var s=vn.extractText(t,!1);if(""===s)return-1;var u=An.createMarkerNode('<span class="highlight-'.concat(a,'"></span>'),a,this.win);if(e){var c=document.createElement("div");if(c.innerHTML=e,c.textContent!==s.slice(r,i))return-1}return vn.highlightMatches(t,[{startIndex:r,endIndex:i,id:n,marker:u}],!1),bt({editableHost:t}),o&&o.notify("change",t),r},updateHighlight:function(t,e,n,r){if(document.documentElement.classList){var i,o=kn(t.querySelectorAll('[data-word-id="'.concat(e,'"]')));try{for(o.s();!(i=o.n()).done;){var a=i.value;r&&a.classList.remove(r),n&&a.classList.add(n)}}catch(t){o.e(t)}finally{o.f()}}},removeHighlight:function(t,e,n){var r,i=kn(t.querySelectorAll('[data-word-id="'.concat(e,'"]')));try{for(i.s();!(r=i.n()).done;)ce(r.value)}catch(t){i.e(t)}finally{i.f()}t.normalize(),bt({editableHost:t}),n&&n.notify("change",t)},hasHighlight:function(t,e){return!!t.querySelectorAll('[data-word-id="'.concat(e,'"]')).length},extractHighlightedRanges:function(t,e){var n="[data-word-id]";e&&(n+='[data-highlight="'.concat(e,'"]'));var r=t.querySelectorAll(n);if(r.length){var i,o={},a=kn(r);try{for(a.s();!(i=a.n()).done;){var s=i.value.getAttribute("data-word-id");o[s]||(o[s]=t.querySelectorAll('[data-word-id="'.concat(s,'"]')))}}catch(t){a.e(t)}finally{a.f()}var u={};for(var c in o){var l=this.extractMarkerNodePosition(t,o[c]);l&&(u[c]=l)}return u}},extractMarkerNodePosition:function(t,e){var n=k();e.length>1?(n.setStartBefore(e[0]),n.setEndAfter(e[e.length-1])):n.selectNode(e[0]);var r=j(n,t);return{start:r.start,end:r.end,text:r.text,nativeRange:n}},cleanupStaleMarkerNodes:function(t,e){var n,r=kn(t.querySelectorAll('span[data-highlight="'.concat(e,'"]')));try{for(r.s();!(n=r.n()).done;){var i=n.value;i.textContent.length||i.remove()}}catch(t){r.e(t)}finally{r.f()}},createMarkerNode:function(t,e,n){var r=w(t,n);return r.setAttribute("data-editable","ui-unwrap"),r.setAttribute("data-highlight",e),r}};const En=An;function Tn(t){return Tn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tn(t)}function xn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||On(t,e)||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 On(t,e){if(t){if("string"==typeof t)return Nn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Nn(t,e):void 0}}function Nn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function jn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,_n(r.key),r)}}function _n(t){var e=function(t){if("object"!=Tn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Tn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tn(e)?e:e+""}function Rn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Rn=function(){return!!t})()}function Bn(t){return Bn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Bn(t)}function Mn(t,e){return Mn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Mn(t,e)}var In=function(t){function e(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),delete(t=function(t,e,n){return e=Bn(e),function(t,e){if(e&&("object"==Tn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Rn()?Reflect.construct(e,n||[],Bn(t).constructor):e.apply(t,n))}(this,e,arguments)).isCursor,t.isSelection=!0,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Mn(t,e)}(e,t),n=e,r=[{key:"text",value:function(){return this.range.toString()}},{key:"html",value:function(){return function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return e.appendChild(t.cloneContents()),e.innerHTML}(this.range)}},{key:"isAllSelected",value:function(){return W(this.host,this.range.startContainer,this.range.startOffset)&&z(this.host,this.range.endContainer,this.range.endOffset)}},{key:"getTextRange",value:function(){return j(this.range,this.host)}},{key:"toString",value:function(){return this.range.toString()}},{key:"isWrappable",value:function(){return ae(this.range)}},{key:"getRects",value:function(){return this.range.getClientRects()}},{key:"link",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t&&(e.href=t);var n=this.createElement(i.linkMarkup.name,i.linkMarkup.attribs);for(var r in e){var o=e[r];void 0!==o&&(null===o?n.removeAttribute(r):n.setAttribute(r,o))}i.linkMarkup.trim&&this.trimRange(),this.forceWrap(n)}},{key:"trimRange",value:function(){var t=this.range.toString(),e=t.search(/\S|$/),n=t.search(/\S[\s]+$/),r=-1===n?0:t.length-(n+1),i=xn(R({root:this.range.commonAncestorContainer,startContainer:this.range.startContainer,startOffset:this.range.startOffset,whitespacesOnTheLeft:e}),2),o=i[0],a=i[1];this.range.setStart(o,a);var s=xn(B({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(i.linkMarkup.name)}},{key:"toggleLink",value:function(t,e){var n=this.getTagsByName(i.linkMarkup.name);if(n.length>=1){var r=n[0];this.isExactSelection(r,"visible")?this.unlink():this.expandTo(r)}else this.link(t,e)}},{key:"highlightComment",value:function(t){var e=t.highlightId,n=t.textRange;En.highlightRange(this.host,e,n.text,n.start,n.end,void 0,"comment")}},{key:"highlight",value:function(t){t.highlightId;var e=this.textBefore(),n=this.text(),r=En.createMarkerNode('<span class="highlight-comment"></span>',this.win);r.setAttribute("data-match",n);var i={startIndex:e.length,endIndex:e.length+n.length,match:n,marker:r};vn.highlightMatches(this.host,[i])}},{key:"toggle",value:function(t){Te(this.host)||this.range.collapsed||(t=this.adoptElement(t),this.range=oe(this.host,this.range,t),this.setVisibleSelection())}},{key:"toggleCustom",value:function(t){var e=t.tagName,n=t.attributes,r=t.trim,i=void 0!==r&&r,o=this.createElement(e,n);i&&this.trimRange(),this.toggle(o)}},{key:"makeCustom",value:function(t){var e=t.tagName,n=t.attributes,r=t.trim,i=void 0!==r&&r,o=this.createElement(e,n);i&&this.trimRange(),this.forceWrap(o)}},{key:"makeBold",value:function(){var t=this.createElement(i.boldMarkup.name,i.boldMarkup.attribs);i.boldMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleBold",value:function(){var t=this.createElement(i.boldMarkup.name,i.boldMarkup.attribs);i.boldMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"giveEmphasis",value:function(){var t=this.createElement(i.italicMarkup.name,i.italicMarkup.attribs);i.italicMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleEmphasis",value:function(){var t=this.createElement(i.italicMarkup.name,i.italicMarkup.attribs);i.italicMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"makeUnderline",value:function(){var t=this.createElement(i.underlineMarkup.name,i.underlineMarkup.attribs);i.underlineMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleUnderline",value:function(){var t=this.createElement(i.underlineMarkup.name,i.underlineMarkup.attribs);i.underlineMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"insertCharacter",value:function(t){var e=this.deleteContent(),n=e.createTextNode(t);return e.insertBefore(n),e.setVisibleSelection(),e}},{key:"surround",value:function(t,e){this.range=pe(this.host,this.range,t,e),this.setVisibleSelection()}},{key:"removeSurround",value:function(t,e){this.range=ge(this.host,this.range,t),this.range=ge(this.host,this.range,e),this.setVisibleSelection()}},{key:"removeChars",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0;e<t.length;e++){var n=t[e];this.range=ge(this.host,this.range,n)}this.setVisibleSelection()}},{key:"toggleSurround",value:function(t,e){this.containsString(t)&&this.containsString(e)?this.removeSurround(t,e):this.surround(t,e)}},{key:"removeFormatting",value:function(t){this.range=fe(this.host,this.range,t),this.setVisibleSelection()}},{key:"deleteExactSurroundingTags",value:function(){var t,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=On(t))){e&&(t=e);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}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 i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(this.getAncestorTags().reverse());try{for(n.s();!(t=n.n()).done;){var r=t.value;if(this.isExactSelection(r)){r.remove();break}}}catch(t){n.e(t)}finally{n.f()}return new e(this.host,this.range)}},{key:"deleteContainedTags",value:function(){return this.getContainedTags().forEach(function(t){return t.remove()}),new e(this.host,this.range)}},{key:"deleteContent",value:function(){return this.range.deleteContents(),new fn(this.host,this.range)}},{key:"expandTo",value:function(t){this.range=ie(this.host,this.range,t),this.setVisibleSelection()}},{key:"collapseAtBeginning",value:function(t){return this.range.collapse(!0),this.setVisibleSelection(),new fn(this.host,this.range)}},{key:"collapseAtEnd",value:function(t){return this.range.collapse(!1),this.setVisibleSelection(),new fn(this.host,this.range)}},{key:"forceWrap",value:function(t){Te(this.host)||this.range.collapsed||(t=this.adoptElement(t),this.range=se(this.host,this.range,t),this.setVisibleSelection())}},{key:"isExactSelection",value:function(t,e){return re(this.range,t,e)}},{key:"containsString",value:function(t){return ye(this.range,t)}},{key:"deleteCharacter",value:function(t){this.range=ge(this.host,this.range,t),this.setVisibleSelection()}}],r&&jn(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(fn);function Pn(t){return Pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pn(t)}function Ln(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Hn(r.key),r)}}function Hn(t){var e=function(t){if("object"!=Pn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Pn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Pn(e)?e:e+""}var Fn=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.host=e&&e.jquery?e[0]:e,this.range=null==n?void 0:n.cloneRange(),this.isAnythingSelected=void 0!==n,this.isCursor=this.isAnythingSelected&&n.collapsed,this.isSelection=this.isAnythingSelected&&!this.isCursor}return e=t,n=[{key:"getCursor",value:function(){if(this.isCursor)return new fn(this.host,this.range)}},{key:"getSelection",value:function(){if(this.isSelection)return new In(this.host,this.range)}},{key:"forceCursor",value:function(){return this.isSelection?this.getSelection().deleteContent():this.getCursor()}},{key:"isDifferentFrom",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new t,n=this.range,r=e.range;return n&&r?!_(n,r):!(!n&&!r)}}],n&&Ln(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n}();function Dn(t){return Dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dn(t)}function Vn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Wn(r.key),r)}}function Wn(t){var e=function(t){if("object"!=Dn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Dn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Dn(e)?e:e+""}var qn=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dispatcher=e,this.win=n||window,this.selection=void 0,this.currentSelection=void 0,this.currentRange=void 0},(e=[{key:"syncSelection",value:function(){try{this.selection=C(this.win)}catch(t){return!1}return!0}},{key:"getRangeContainer",value:function(){var t,e=this.syncSelection();if(null!==(t=this.selection)&&void 0!==t&&t.rangeCount&&e){var n=this.selection.getRangeAt(0),r=I(n.commonAncestorContainer);if(r)return new Fn(r,n)}return new Fn}},{key:"getFreshRange",value:function(){return this.getRangeContainer()}},{key:"getFreshSelection",value:function(){var t=this.getRangeContainer();return t.isCursor?t.getCursor(this.win):t.getSelection(this.win)}},{key:"getSelection",value:function(){return this.currentSelection}},{key:"forceCursor",value:function(){return this.getRangeContainer().forceCursor()}},{key:"selectionChanged",value:function(){var t=this.getRangeContainer();if(t.isDifferentFrom(this.currentRange)){var e=this.currentSelection;this.currentRange=t,e&&(e.isCursor&&!this.currentRange.isCursor?this.dispatcher.notify("cursor",e.host):e.isSelection&&!this.currentRange.isSelection&&this.dispatcher.notify("selection",e.host)),this.currentRange.isCursor?(this.currentSelection=new fn(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("cursor",this.currentSelection.host,this.currentSelection)):this.currentRange.isSelection?(this.currentSelection=new In(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("selection",this.currentSelection.host,this.currentSelection)):this.currentSelection=void 0}}}])&&Vn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Un(t){return Un="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Un(t)}function $n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,zn(r.key),r)}}function zn(t){var e=function(t){if("object"!=Un(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Un(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Un(e)?e:e+""}var Kn=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),sn(this),this.selectionWatcher=e}return e=t,r=[{key:"getNodeToRemove",value:function(e,n){if(0===e.startOffset){var r=e.startContainer;if(r.nodeType===h&&(r=r.parentNode),r!==n){var i=k();if(i.setStartBefore(r.firstChild),i.setEndAfter(r.lastChild),a=e,!((o=i).compareBoundaryPoints(Range.START_TO_START,a)<=0&&o.compareBoundaryPoints(Range.END_TO_END,a)>=0)){var o,a;if(e.startContainer.nodeType===h){var s=[h,f],u=r.firstChild;do{if(-1!==s.indexOf(u.nodeType))break}while(u=u.nextSibling);if(u!==e.startContainer)return}var c=e.cloneRange();return c.setStartBefore(r),t.getNodeToRemove(c,n)||r}}}}}],(n=[{key:"dispatchKeyEvent",value:function(t,e,n){switch(t.keyCode){case this.key.left:return this.notify(e,"left",t);case this.key.right:return this.notify(e,"right",t);case this.key.up:return this.notify(e,"up",t);case this.key.down:return this.notify(e,"down",t);case this.key.tab:return t.shiftKey?this.notify(e,"shiftTab",t):this.notify(e,"tab",t);case this.key.esc:return this.notify(e,"esc",t);case this.key.backspace:return this.preventContenteditableBug(e,t),this.notify(e,"backspace",t);case this.key.delete:return this.preventContenteditableBug(e,t),this.notify(e,"delete",t);case this.key.enter:return t.shiftKey?this.notify(e,"shiftEnter",t):this.notify(e,"enter",t);case this.key.ctrl:case this.key.shift:case this.key.alt:case 224:case 17:case 91:case 93:return;default:if(t.keyCode===this.key.b&&(t.ctrlKey||t.metaKey))return this.notify(e,"bold",t);if(t.keyCode===this.key.i&&(t.ctrlKey||t.metaKey))return this.notify(e,"italic",t);if(this.preventContenteditableBug(e,t),!n)return;if(!t.ctrlKey&&!t.metaKey)return this.notify(e,"character",t)}}},{key:"preventContenteditableBug",value:function(e,n){if(an&&!n.ctrlKey&&!n.metaKey){var r=this.selectionWatcher.getFreshRange();if(r.isSelection){var i=t.getNodeToRemove(r.range,e);i&&i.remove()}}}}])&&$n(e.prototype,n),r&&$n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function Qn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}Kn.key=Kn.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 Xn=function(t){return Array.isArray(t)&&2===t.length},Gn=function(t){return/^[«»"“”„]$/.test(t)},Yn=function(t){return/^[‘’‹›‚']$/.test(t)},Jn=function(t){return/^[’']$/.test(t)},Zn=function(t){return/\s|[>\-–—]/.test(t)},tr=function(t,e,n,r,i){var o,a=Yn(n);if(Gn(n)||a){var s=e.quotes,u=e.singleQuotes;if(n!==s[0]&&n!==s[1]&&n!==u[0]&&n!==u[1]){var c=t.startOffset,l=function(t,e,n,r){var i,o,a=r.quotes,s=r.singleQuotes;if(n&&(i=t)[o=e-2]&&Gn(i[o]))return s[0];if(function(t,e){return!!t[e]&&!Zn(t[e])}(t,e-2)){if(n){if(function(t,e){return!!t[e]&&(n=t[e],!/^\s$/.test(n));var n}(t,e))return;if(!function(t,e,n){if(e<=0)return!1;for(var r=e-1;r>=0;r--)if(Yn(t[r])&&!Jn(n)&&!Jn(t[r]))return t[r]===n;return!1}(t,e,s[0]))return;return s[1]}return a[1]}return function(t,e){return e<0||Zn(t[e])}(t,e-2)?n?s[0]:a[0]:void 0}(function(t){if(Array.isArray(t))return Qn(t)}(o=t.startContainer.textContent)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(o)||function(t,e){if(t){if("string"==typeof t)return Qn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qn(t,e):void 0}}(o)||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.")}(),c,a,e);l&&function(t,e,n){var r=null==t?void 0:t.startContainer,i=null==r?void 0:r.nodeValue;if(!i)return!1;var o=Math.min(e,i.length);return r.insertData(o,n),r.deleteData(o+n.length,1),!0}(t,c-1,l)&&r.ownerDocument.defaultView.getSelection().collapse(t.startContainer,null!=i?i:c)}}};function er(t){return er="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(t)}function nr(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return rr(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?rr(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},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(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function rr(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ir(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,or(r.key),r)}}function or(t){var e=function(t){if("object"!=er(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=er(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==er(e)?e:e+""}var ar=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=e.win;sn(this,e),this.document=n.document,this.config=e.config,this.editable=e,this.editableSelector=e.editableSelector,this.selectionWatcher=new qn(this,n),this.keyboard=new Kn(this.selectionWatcher),this.activeListeners=[],this.setup(),this.getEditableBlockByEvent=function(t){return S(t.target,e.editableSelector)}},e=[{key:"setupDocumentListener",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r={event:t,listener:e.bind(this),capture:n};return this.activeListeners.push(r),this.document.addEventListener(t,r.listener,n),this}},{key:"setup",value:function(){this.setupKeyboardEvents(),this.setupEventListeners()}},{key:"unload",value:function(){this.off();var t,e=nr(this.activeListeners);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(t){e.e(t)}finally{e.f()}this.activeListeners.length=0}},{key:"suspend",value:function(){if(!this.suspended){this.suspended=!0;var t,e=nr(this.activeListeners);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(t){e.e(t)}finally{e.f()}this.activeListeners.length=0}}},{key:"continue",value:function(){this.suspended&&(this.suspended=!1,this.setupEventListeners())}},{key:"setupEventListeners",value:function(){this.setupElementListeners(),this.setupKeydownListener(),on?this.setupSelectionChangeListeners():this.setupSelectionChangeFallbackListeners()}},{key:"setupElementListeners",value:function(){var t={offset:void 0};this.setupDocumentListener("focus",function(t){var e=this.getEditableBlockByEvent(t);e&&(t.target.getAttribute(i.pastingAttribute)||(this.selectionWatcher.syncSelection(),this.notify("focus",e)))},!0).setupDocumentListener("blur",function(t){var e=this.getEditableBlockByEvent(t);e&&(e.getAttribute(i.pastingAttribute)||this.notify("blur",e))},!0).setupDocumentListener("copy",function(t){var e=this.getEditableBlockByEvent(t);if(e){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&this.notify("clipboard",e,"copy",n)}}).setupDocumentListener("cut",function(t){var e=this.getEditableBlockByEvent(t);if(e){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&this.notify("clipboard",e,"cut",n)}}).setupDocumentListener("paste",function(t){var e=this.getEditableBlockByEvent(t);if(e){t.preventDefault();var n,r=this.selectionWatcher.getFreshSelection(),i=t.clipboardData.getData("text/html")||t.clipboardData.getData("text/plain"),o=Ze(e,r,i),a=o.blocks,s=o.cursor;a.length?(n=t.target.innerText,/\S+\s{1}$/.test(n)&&s.retainVisibleSelection(function(){e.innerHTML=function(t,e){if(!t)return"";var n=(t="".concat(t)).lastIndexOf(e);return-1===n?t:"".concat(t.slice(0,n)).concat(" ").concat(t.slice(n+6))}(e.innerHTML,"&nbsp;")}),this.notify("paste",e,a,s),this.notify("change",e)):s.setVisibleSelection()}}).setupDocumentListener("input",function(e){var n=this.getEditableBlockByEvent(e);if(n){if(function(t,e){var n=t.smartQuotes,r=t.quotes,i=t.singleQuotes;return!!n&&Xn(r)&&Xn(i)&&e.isContentEditable}(i,e.target)){var r,o=this.selectionWatcher.getFreshSelection();t.offset=null===(r=o.range)||void 0===r?void 0:r.startOffset,setTimeout(function(){tr(o.range,i,e.data,e.target,t.offset)},300)}this.notify("change",n)}}).setupDocumentListener("formatEditable",function(t){var e=this.getEditableBlockByEvent(t);e&&this.notify("change",e)})}},{key:"dispatchSwitchEvent",value:function(t,e,n){if(!(t.altKey||t.ctrlKey||t.metaKey||t.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()&&(t.preventDefault(),t.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",e,n,r)),"down"===n&&r.isAtLastLine()&&(t.preventDefault(),t.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",e,n,r)))}}},{key:"setupKeydownListener",value:function(){this.setupDocumentListener("keydown",function(t){var e=this.getEditableBlockByEvent(t);e&&this.keyboard.dispatchKeyEvent(t,e,!1)},!0)}},{key:"setupKeyboardEvents",value:function(){var t=this;this.keyboard.on("up",function(e){t.dispatchSwitchEvent(e,this,"up")}).on("down",function(e){t.dispatchSwitchEvent(e,this,"down")}).on("backspace",function(e){var n=t.selectionWatcher.getFreshRange();if(n.isCursor){var r=n.getCursor();r.isAtBeginning()&&(e.preventDefault(),e.stopPropagation(),t.notify("merge",this,"before",r))}}).on("delete",function(e){var n=t.selectionWatcher.getFreshRange();if(n.isCursor){var r=n.getCursor();r.isAtTextEnd()&&(e.preventDefault(),e.stopPropagation(),t.notify("merge",this,"after",r))}}).on("enter",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshRange().forceCursor();n.isAtTextEnd()?t.notify("insert",this,"after",n):n.isAtBeginning()?t.notify("insert",this,"before",n):t.notify("split",this,n.before(),n.after(),n)}).on("shiftEnter",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.forceCursor();t.notify("newline",this,n)}).on("bold",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshSelection();n.isSelection&&t.notify("toggleBold",n)}).on("italic",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshSelection();n.isSelection&&t.notify("toggleEmphasis",n)}).on("character",function(e){t.notify("change",this)})}},{key:"setupSelectionChangeListeners",value:function(){var t=this,e=!1,n=!1,r=this.selectionWatcher;this.setupDocumentListener("selectionchange",function(i){var o=t.selectionWatcher.getFreshSelection();o&&o.isSelection&&o.isAtBeginning()&&o.isAtEnd()?t.notify("selectToBoundary",o.host,i,"both"):o&&o.isSelection&&o.isAtBeginning()?t.notify("selectToBoundary",o.host,i,"start"):o&&o.isSelection&&o.isAtEnd()&&t.notify("selectToBoundary",o.host,i,"end"),n?e=!0:r.selectionChanged()}),this.setupDocumentListener("mousedown",function(t){this.getEditableBlockByEvent(t)&&(!1===this.config.mouseMoveSelectionChanges&&(n=!0,setTimeout(function(){return r.selectionChanged()},0)),this.document.addEventListener("mouseup",function(){n=!1,e&&(e=!1,r.selectionChanged())},{capture:!0,once:!0}))})}},{key:"setupSelectionChangeFallbackListeners",value:function(){var t=this;this.setupDocumentListener("mouseup",function(){setTimeout(function(){return t.selectionWatcher.selectionChanged()},0)}),this.setupDocumentListener("keyup",function(e){t.getEditableBlockByEvent(e)&&t.selectionWatcher.selectionChanged()})}}],e&&ir(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();const sr=function(t,e){return t===e||t!=t&&e!=e},ur=function(t,e){for(var n=t.length;n--;)if(sr(t[n][0],e))return n;return-1};var cr=Array.prototype.splice;function lr(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}lr.prototype.clear=function(){this.__data__=[],this.size=0},lr.prototype.delete=function(t){var e=this.__data__,n=ur(e,t);return!(n<0||(n==e.length-1?e.pop():cr.call(e,n,1),--this.size,0))},lr.prototype.get=function(t){var e=this.__data__,n=ur(e,t);return n<0?void 0:e[n][1]},lr.prototype.has=function(t){return ur(this.__data__,t)>-1},lr.prototype.set=function(t,e){var n=this.__data__,r=ur(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};const fr=lr,hr="object"==typeof t.g&&t.g&&t.g.Object===Object&&t.g;var dr="object"==typeof self&&self&&self.Object===Object&&self;const vr=hr||dr||Function("return this")(),pr=vr.Symbol;var gr=Object.prototype,yr=gr.hasOwnProperty,mr=gr.toString,br=pr?pr.toStringTag:void 0;var wr=Object.prototype.toString;var Sr=pr?pr.toStringTag:void 0;const kr=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Sr&&Sr in Object(t)?function(t){var e=yr.call(t,br),n=t[br];try{t[br]=void 0;var r=!0}catch(t){}var i=mr.call(t);return r&&(e?t[br]=n:delete t[br]),i}(t):function(t){return wr.call(t)}(t)},Cr=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Ar=function(t){if(!Cr(t))return!1;var e=kr(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},Er=vr["__core-js_shared__"];var Tr,xr=(Tr=/[^.]+$/.exec(Er&&Er.keys&&Er.keys.IE_PROTO||""))?"Symbol(src)_1."+Tr:"";var Or=Function.prototype.toString;var Nr=/^\[object .+?Constructor\]$/,jr=Function.prototype,_r=Object.prototype,Rr=jr.toString,Br=_r.hasOwnProperty,Mr=RegExp("^"+Rr.call(Br).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const Ir=function(t){return!(!Cr(t)||(e=t,xr&&xr in e))&&(Ar(t)?Mr:Nr).test(function(t){if(null!=t){try{return Or.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e},Pr=function(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Ir(n)?n:void 0},Lr=Pr(vr,"Map"),Hr=Pr(Object,"create");var Fr=Object.prototype.hasOwnProperty;var Dr=Object.prototype.hasOwnProperty;function Vr(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Vr.prototype.clear=function(){this.__data__=Hr?Hr(null):{},this.size=0},Vr.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Vr.prototype.get=function(t){var e=this.__data__;if(Hr){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return Fr.call(e,t)?e[t]:void 0},Vr.prototype.has=function(t){var e=this.__data__;return Hr?void 0!==e[t]:Dr.call(e,t)},Vr.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Hr&&void 0===e?"__lodash_hash_undefined__":e,this};const Wr=Vr,qr=function(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map};function Ur(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Ur.prototype.clear=function(){this.size=0,this.__data__={hash:new Wr,map:new(Lr||fr),string:new Wr}},Ur.prototype.delete=function(t){var e=qr(this,t).delete(t);return this.size-=e?1:0,e},Ur.prototype.get=function(t){return qr(this,t).get(t)},Ur.prototype.has=function(t){return qr(this,t).has(t)},Ur.prototype.set=function(t,e){var n=qr(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};const $r=Ur;function zr(t){var e=this.__data__=new fr(t);this.size=e.size}zr.prototype.clear=function(){this.__data__=new fr,this.size=0},zr.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},zr.prototype.get=function(t){return this.__data__.get(t)},zr.prototype.has=function(t){return this.__data__.has(t)},zr.prototype.set=function(t,e){var n=this.__data__;if(n instanceof fr){var r=n.__data__;if(!Lr||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new $r(r)}return n.set(t,e),this.size=n.size,this};const Kr=zr,Qr=function(){try{var t=Pr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Xr=function(t,e,n){"__proto__"==e&&Qr?Qr(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n},Gr=function(t,e,n){(void 0!==n&&!sr(t[e],n)||void 0===n&&!(e in t))&&Xr(t,e,n)},Yr=function(t,e,n){for(var r=-1,i=Object(t),o=n(t),a=o.length;a--;){var s=o[++r];if(!1===e(i[s],s,i))break}return t};var Jr="object"==typeof exports&&exports&&!exports.nodeType&&exports,Zr=Jr&&"object"==typeof module&&module&&!module.nodeType&&module,ti=Zr&&Zr.exports===Jr?vr.Buffer:void 0,ei=ti?ti.allocUnsafe:void 0;const ni=vr.Uint8Array,ri=function(t,e){var n,r,i=e?(n=t.buffer,r=new n.constructor(n.byteLength),new ni(r).set(new ni(n)),r):t.buffer;return new t.constructor(i,t.byteOffset,t.length)};var ii=Object.create;const oi=function(){function t(){}return function(e){if(!Cr(e))return{};if(ii)return ii(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}(),ai=(si=Object.getPrototypeOf,ui=Object,function(t){return si(ui(t))});var si,ui,ci=Object.prototype;const li=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ci)},fi=function(t){return null!=t&&"object"==typeof t},hi=function(t){return fi(t)&&"[object Arguments]"==kr(t)};var di=Object.prototype,vi=di.hasOwnProperty,pi=di.propertyIsEnumerable;const gi=hi(function(){return arguments}())?hi:function(t){return fi(t)&&vi.call(t,"callee")&&!pi.call(t,"callee")},yi=Array.isArray,mi=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},bi=function(t){return null!=t&&mi(t.length)&&!Ar(t)};var wi="object"==typeof exports&&exports&&!exports.nodeType&&exports,Si=wi&&"object"==typeof module&&module&&!module.nodeType&&module,ki=Si&&Si.exports===wi?vr.Buffer:void 0;const Ci=(ki?ki.isBuffer:void 0)||function(){return!1};var Ai=Function.prototype,Ei=Object.prototype,Ti=Ai.toString,xi=Ei.hasOwnProperty,Oi=Ti.call(Object);var Ni={};Ni["[object Float32Array]"]=Ni["[object Float64Array]"]=Ni["[object Int8Array]"]=Ni["[object Int16Array]"]=Ni["[object Int32Array]"]=Ni["[object Uint8Array]"]=Ni["[object Uint8ClampedArray]"]=Ni["[object Uint16Array]"]=Ni["[object Uint32Array]"]=!0,Ni["[object Arguments]"]=Ni["[object Array]"]=Ni["[object ArrayBuffer]"]=Ni["[object Boolean]"]=Ni["[object DataView]"]=Ni["[object Date]"]=Ni["[object Error]"]=Ni["[object Function]"]=Ni["[object Map]"]=Ni["[object Number]"]=Ni["[object Object]"]=Ni["[object RegExp]"]=Ni["[object Set]"]=Ni["[object String]"]=Ni["[object WeakMap]"]=!1;var ji="object"==typeof exports&&exports&&!exports.nodeType&&exports,_i=ji&&"object"==typeof module&&module&&!module.nodeType&&module,Ri=_i&&_i.exports===ji&&hr.process,Bi=function(){try{return _i&&_i.require&&_i.require("util").types||Ri&&Ri.binding&&Ri.binding("util")}catch(t){}}(),Mi=Bi&&Bi.isTypedArray;const Ii=Mi?function(t){return function(e){return t(e)}}(Mi):function(t){return fi(t)&&mi(t.length)&&!!Ni[kr(t)]},Pi=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};var Li=Object.prototype.hasOwnProperty;const Hi=function(t,e,n){var r=t[e];Li.call(t,e)&&sr(r,n)&&(void 0!==n||e in t)||Xr(t,e,n)};var Fi=/^(?:0|[1-9]\d*)$/;const Di=function(t,e){var n=typeof t;return!!(e=e??9007199254740991)&&("number"==n||"symbol"!=n&&Fi.test(t))&&t>-1&&t%1==0&&t<e};var Vi=Object.prototype.hasOwnProperty;const Wi=function(t,e){var n=yi(t),r=!n&&gi(t),i=!n&&!r&&Ci(t),o=!n&&!r&&!i&&Ii(t),a=n||r||i||o,s=a?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],u=s.length;for(var c in t)!e&&!Vi.call(t,c)||a&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Di(c,u))||s.push(c);return s};var qi=Object.prototype.hasOwnProperty;const Ui=function(t){if(!Cr(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=li(t),n=[];for(var r in t)("constructor"!=r||!e&&qi.call(t,r))&&n.push(r);return n},$i=function(t){return bi(t)?Wi(t,!0):Ui(t)},zi=function(t){return function(t,e,n,r){var i=!n;n||(n={});for(var o=-1,a=e.length;++o<a;){var s=e[o],u=r?r(n[s],t[s],s,n,t):void 0;void 0===u&&(u=t[s]),i?Xr(n,s,u):Hi(n,s,u)}return n}(t,$i(t))},Ki=function(t,e,n,r,i,o,a){var s,u=Pi(t,n),c=Pi(e,n),l=a.get(c);if(l)Gr(t,n,l);else{var f=o?o(u,c,n+"",t,e,a):void 0,h=void 0===f;if(h){var d=yi(c),v=!d&&Ci(c),p=!d&&!v&&Ii(c);f=c,d||v||p?yi(u)?f=u:fi(s=u)&&bi(s)?f=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(u):v?(h=!1,f=function(t,e){if(e)return t.slice();var n=t.length,r=ei?ei(n):new t.constructor(n);return t.copy(r),r}(c,!0)):p?(h=!1,f=ri(c,!0)):f=[]:function(t){if(!fi(t)||"[object Object]"!=kr(t))return!1;var e=ai(t);if(null===e)return!0;var n=xi.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Ti.call(n)==Oi}(c)||gi(c)?(f=u,gi(u)?f=zi(u):Cr(u)&&!Ar(u)||(f=function(t){return"function"!=typeof t.constructor||li(t)?{}:oi(ai(t))}(c))):h=!1}h&&(a.set(c,f),i(f,c,r,o,a),a.delete(c)),Gr(t,n,f)}},Qi=function t(e,n,r,i,o){e!==n&&Yr(n,function(a,s){if(o||(o=new Kr),Cr(a))Ki(e,n,s,r,t,i,o);else{var u=i?i(Pi(e,s),a,s+"",e,n,o):void 0;void 0===u&&(u=a),Gr(e,s,u)}},$i)},Xi=function(t){return t};var Gi=Math.max;const Yi=Qr?function(t,e){return Qr(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:Xi;var Ji=Date.now;const Zi=function(t){var e=0,n=0;return function(){var r=Ji(),i=16-(r-n);if(n=r,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Yi),to=function(t,e){return Zi(function(t,e,n){return e=Gi(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,o=Gi(r.length-e,0),a=Array(o);++i<o;)a[i]=r[e+i];i=-1;for(var s=Array(e+1);++i<e;)s[i]=r[i];return s[e]=n(a),function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}(t,this,s)}}(t,e,Xi),t+"")},eo=(no=function(t,e,n){Qi(t,e,n)},to(function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(i=no.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(t,e,n){if(!Cr(n))return!1;var r=typeof e;return!!("number"==r?bi(n)&&Di(e,n.length):"string"==r&&e in n)&&sr(n[e],t)}(e[0],e[1],o)&&(i=r<3?void 0:i,r=1),t=Object(t);++n<r;){var a=e[n];a&&no(t,a,n)}return t}));var no;function ro(t){return ro="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ro(t)}function io(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,oo(r.key),r)}}function oo(t){var e=function(t){if("object"!=ro(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ro(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ro(e)?e:e+""}var ao=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.spellcheckService=e},(e=[{key:"check",value:function(t,e){if(!t)return e(null);var n=Ht(t);this.spellcheckService(n,function(t){return t&&t.length>0?e(null,t):e(null)})}}])&&io(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function so(t){return so="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},so(t)}function uo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function co(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,lo(r.key),r)}}function lo(t){var e=function(t){if("object"!=so(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=so(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==so(e)?e:e+""}var fo={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"},ho=new RegExp("[".concat("\\u2000-\\u200A\\u202F\\u205F\\u3000","]"),"g"),vo=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.marker=e},(e=[{key:"findMatches",value:function(t){var e=this;if(t)return function(t){return function(t){if(Array.isArray(t))return uo(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return uo(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uo(t,e):void 0}}(t)||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.")}()}(t.matchAll(ho)).map(function(t){return e.prepareMatch(t)})}},{key:"prepareMatch",value:function(t){var e,n=t.index,r=(e=t[0].charCodeAt(0),"".concat(e.toString(16).toUpperCase())),i=fo[r];return{startIndex:n,endIndex:n+t.length,match:t[0],title:"".concat(i," (\\u").concat(r,")"),marker:this.marker}}}])&&co(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function po(t){return po="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},po(t)}function go(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,yo(r.key),r)}}function yo(t){var e=function(t){if("object"!=po(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=po(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==po(e)?e:e+""}var mo=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.matches=[]},e=[{key:"addMatches",value:function(t){null!=t&&t.length&&(this.matches=function(t,e){for(var n,r=t.length,i=e.length,o=-1,a=[],s={a1:t,i1:0,a2:e,i2:0};s.i1<r||s.i2<i;)(n=bo(s)).startIndex>=o&&a.push(n),o=n.endIndex;return a}(this.matches,t))}}],e&&go(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function bo(t){var e=t.i1,n=t.i2,r=t.a1[e],i=t.a2[n];return r&&i&&r.startIndex<i.startIndex?(t.i1=e+1,r):r&&i?(t.i2=n+1,i):r?(t.i1=e+1,r):i?(t.i2=n+1,i):void 0}function wo(t){return wo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wo(t)}function So(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return ko(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ko(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},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(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function ko(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Co(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ao(r.key),r)}}function Ao(t){var e=function(t){if("object"!=wo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=wo(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wo(e)?e:e+""}var Eo=function(){return t=function t(e,n,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.editable=e,this.win=e.win,this.focusedEditableHost=void 0,this.currentlyCheckedEditableHost=void 0,this.timeout={},this.config=eo({},{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 i=this.config.spellcheck.spellcheckService,o=this.config.spellcheck.marker,a=this.config.whitespace.marker,s=En.createMarkerNode(a,"whitespace",this.win);this.spellcheckMarkerNode=En.createMarkerNode(o,"spellcheck",this.win),this.spellcheckService=new ao(i),this.whitespace=new vo(s),this.setupListeners()},e=[{key:"setupListeners",value:function(){var t=this;this.config.checkOnFocus&&(this.editable.on("focus",function(){return t.onFocus.apply(t,arguments)}),this.editable.on("blur",function(){return t.onBlur.apply(t,arguments)})),(this.config.checkOnChange||this.config.removeOnCorrection)&&this.editable.on("change",function(){return t.onChange.apply(t,arguments)}),this.config.checkOnInit&&this.editable.on("init",function(){return t.onInit.apply(t,arguments)})}},{key:"onInit",value:function(t){this.highlight(t)}},{key:"onFocus",value:function(t){this.focusedEditableHost!==t&&(this.focusedEditableHost=t,this.editableHasChanged(t))}},{key:"onBlur",value:function(t){this.focusedEditableHost===t&&(this.focusedEditableHost=void 0)}},{key:"onChange",value:function(t){this.config.checkOnChange&&this.editableHasChanged(t,this.config.throttle),this.config.removeOnCorrection&&this.removeHighlightsAtCursor(t)}},{key:"editableHasChanged",value:function(t,e){var n=this;this.timeout.id&&this.timeout.editableHost===t&&clearTimeout(this.timeout.id);var r=setTimeout(function(){n.highlight(t),n.timeout={}},e||0);this.timeout={id:r,editableHost:t}}},{key:"highlight",value:function(t){var e=this,n=vn.extractText(t);this.spellcheckService.check(n,function(n,r){if(!n&&t.isConnected){var i=vn.extractText(t),o=new mo,a=function(t,e,n){return yn(t,e,"word",n)}(i,r,e.spellcheckMarkerNode);o.addMatches(a),a=e.whitespace.findMatches(i),o.addMatches(a),e.safeHighlightMatches(t,o.matches)}})}},{key:"safeHighlightMatches",value:function(t,e){var n=this,r=this.editable.getSelection(t);r?r.retainVisibleSelection(function(){n.highlightMatches(t,e)}):this.highlightMatches(t,e),this.editable.dispatcher&&this.editable.dispatcher.notify("spellcheckUpdated",t)}},{key:"highlightMatches",value:function(t,e){this.removeHighlights(t),e&&e.length>0&&vn.highlightMatches(t,e)}},{key:"removeHighlights",value:function(t){t=b(t,this.win.document);var e,n=So(m('[data-highlight="spellcheck"], [data-highlight="whitespace"]',t));try{for(n.s();!(e=n.n()).done;)ce(e.value)}catch(t){n.e(t)}finally{n.f()}}},{key:"removeHighlightsAtCursor",value:function(t){t=b(t,this.win.document);var e=this.editable.getSelection(t);if(e&&e.isCursor){var n,r=e.range.startContainer;r.nodeType===h&&(r=r.parentNode);do{if(r===t)return;var i=r.getAttribute("data-highlight");if("spellcheck"===i||"whitespace"===i){n=r.getAttribute("data-word-id");break}}while(r=r.parentNode);n&&e.retainVisibleSelection(function(){var e,r=So(m('[data-word-id="'.concat(n,'"]'),t));try{for(r.s();!(e=r.n()).done;)ce(e.value)}catch(t){r.e(t)}finally{r.f()}})}}}],e&&Co(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function To(){if(!1!==i.log&&t.g.console){var e=1===arguments.length?arguments[0]:Array.from(arguments);return 1!==arguments.length&&"trace"===e[e.length-1]&&(e.pop(),console.trace&&console.trace()),console.log(e)}}function xo(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Oo(t){return function(t){if(Array.isArray(t))return xo(t)}(e=new y(t,"getNextTextNode"))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return xo(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xo(t,e):void 0}}(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 e}function No(t){for(var e,n=t.textNodes,r=t.absOffset,i=0,o=0,a=0;a<n.length;a++){var s=n[a];if(r<=i+s.textContent.length){e=s,o=r-i;break}i+=s.textContent.length}return{node:e,relativeOffset:o}}function jo(t){t.rightLimit=t.currentOffset,t.currentOffset=Math.floor((t.currentOffset+t.leftLimit)/2)}function _o(t){t.leftLimit=t.currentOffset,t.currentOffset=Math.ceil((t.currentOffset+t.rightLimit)/2)}function Ro(t){var e=No({textNodes:t.textNodes,absOffset:t.offset}),n=e.node,r=e.relativeOffset,i=n.ownerDocument.createRange();return i.setStart(n,r),i.collapse(!0),i}function Bo(t){return Bo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bo(t)}function Mo(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Io(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Io(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},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(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function Io(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Po(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Lo(r.key),r)}}function Lo(t){var e=function(t){if("object"!=Bo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Bo(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bo(e)?e:e+""}var Ho=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n,r={window,defaultBehavior:!0,mouseMoveSelectionChanges:!1,browserSpellcheck:!0};this.config=Object.assign(r,e),this.win=this.config.window,this.editableSelector=".".concat(i.editableClass),this.dispatcher=new ar(this),!0===this.config.defaultBehavior&&this.dispatcher.on((n=function(t){var e=t.win.document;return{focus:function(t){L(t)&&t.appendChild(e.createTextNode("\ufeff"))},blur:function(t){e.activeElement!==t&&Ft(t)},selection:function(t,e){To(e?"Default selection behavior":"Default selection empty behavior")},cursor:function(t,e){To(e?"Default cursor behavior":"Default cursor empty behavior")},newline:function(t,n){if(n.isAtTextEnd()){var r,i=e.createElement("br");n.insertBefore(i),(null===(r=i.nextSibling)||void 0===r?void 0:r.nodeType)===h&&"\ufeff"===i.nextSibling.textContent[0]||n.insertAfter(e.createTextNode("\ufeff"))}else n.insertBefore(e.createElement("br"));n.setVisibleSelection()},insert:function(t,e,n){var r=t.parentNode,i=t.cloneNode(!1);switch(i.id&&i.removeAttribute("id"),e){case"before":r.insertBefore(i,t),t.focus();break;case"after":r.insertBefore(i,t.nextSibling),i.focus()}},split:function(t,e,n,r){var i=t.cloneNode(!1);for(i.appendChild(e),t.parentNode.insertBefore(i,t);t.firstChild;)t.removeChild(t.firstChild);t.appendChild(n),Pt(i),Pt(t),t.focus()},merge:function(e,n,r){var i,o;switch(n){case"before":i=Ce(e),o=e;break;case"after":i=e,o=ke(e)}i&&o&&(r=i.childNodes.length>0?t.appendTo(i,o.innerHTML):t.prependTo(i,o.innerHTML),o.remove(),r.save(),Pt(i),r.restore(),r.setVisibleSelection())},empty:function(t){To("Default empty behavior")},switch:function(t,e,n){switch(e){case"before":var r=Ce(t);r&&(n.moveAtTextEnd(r),n.setVisibleSelection());break;case"after":var i=ke(t);i&&(n.moveAtBeginning(i),n.setVisibleSelection())}},move:function(t,e,n){To("Default move behavior")},paste:function(e,n,r){if(0!==n.length){if(r.insertBefore(n.shift()),0===n.length)return r.setVisibleSelection();var i=e.parentNode,o=e;n.forEach(function(t){var n=e.cloneNode(!1);n.id&&n.removeAttribute("id");var r=Wt(t);n.appendChild(r),i.insertBefore(n,o.nextSibling),o=n}),t.createCursorAtEnd(o).setVisibleSelection()}},clipboard:function(t,e,n){To("Default clipboard behavior")},toggleBold:function(t){t.toggleBold()},toggleEmphasis:function(t){t.toggleEmphasis()}}}(this),{focus:function(t){n.focus(t)},blur:function(t){n.blur(t)},flow:function(t,e){n.flow(t,e)},selection:function(t,e){n.selection(t,e)},cursor:function(t,e){n.cursor(t,e)},newline:function(t,e){n.newline(t,e)},split:function(t,e,r,i){n.split(t,e,r,i)},insert:function(t,e,r){n.insert(t,e,r)},merge:function(t,e,r){n.merge(t,e,r)},empty:function(t){n.empty(t)},switch:function(t,e,r){n.switch(t,e,r)},move:function(t,e,r){n.move(t,e,r)},clipboard:function(t,e,r){n.clipboard(t,e,r)},paste:function(t,e,r){n.paste(t,e,r)},toggleBold:function(t){n.toggleBold(t)},toggleEmphasis:function(t){n.toggleEmphasis(t)}}))},e=[{key:"add",value:function(t,e){return this.enable(t,e),this}},{key:"remove",value:function(t){var e=m(t,this.win.document);this.disable(e);var n,r=Mo(e);try{for(r.s();!(n=r.n()).done;)n.value.classList.remove(i.editableDisabledClass)}catch(t){r.e(t)}finally{r.f()}return this}},{key:"disable",value:function(t){var e,n=Mo(m(t||".".concat(i.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)Ee(e.value)}catch(t){n.e(t)}finally{n.f()}return this}},{key:"enable",value:function(t,e){var n,r=null!=e?e:{},o=r.normalize,a=void 0===o?"boolean"==typeof e&&e:o,s=r.plainText,u=void 0!==s&&s,c=this.config.browserSpellcheck,l=Mo(m(t||".".concat(i.editableDisabledClass),this.win.document));try{for(l.s();!(n=l.n()).done;){var f=n.value;Ae(f,{normalize:a,plainText:u,shouldSpellcheck:c}),this.dispatcher.notify("init",f)}}catch(t){l.e(t)}finally{l.f()}return this}},{key:"suspend",value:function(t){var e,n=Mo(m(t||".".concat(i.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)e.value.removeAttribute("contenteditable")}catch(t){n.e(t)}finally{n.f()}return this.dispatcher.suspend(),this}},{key:"continue",value:function(t){var e,n=Mo(m(t||".".concat(i.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)e.value.setAttribute("contenteditable",!0)}catch(t){n.e(t)}finally{n.f()}return this.dispatcher.continue(),this}},{key:"createCursor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"beginning",n=fn.findHost(t,this.editableSelector);if(n){var r=k();return"beginning"===e||"end"===e?(r.selectNodeContents(t),r.collapse("beginning"===e)):t!==n?"before"===e?(r.setStartBefore(t),r.setEndBefore(t)):"after"===e&&(r.setStartAfter(t),r.setEndAfter(t)):o("EditableJS: cannot create cursor outside of an editable block."),new fn(n,r)}}},{key:"createCursorAtCharacterOffset",value:function(t){var e=t.element,n=t.offset,r=No({textNodes:Oo(e),absOffset:n}),i=r.node,o=r.relativeOffset,a=k();a.setStart(i,o),a.collapse(!0);var s=fn.findHost(e,this.editableSelector),u=new fn(s,a);return u.setVisibleSelection(),u}},{key:"createCursorAtBeginning",value:function(t){return this.createCursor(t,"beginning")}},{key:"createCursorAtEnd",value:function(t){return this.createCursor(t,"end")}},{key:"createCursorBefore",value:function(t){return this.createCursor(t,"before")}},{key:"createCursorAfter",value:function(t){return this.createCursor(t,"after")}},{key:"getContent",value:function(t){return Dt(t)}},{key:"appendTo",value:function(t,e){var n=qt(t,this.win.document),r=this.createCursor(n,"end");return r.insertAfter("string"==typeof e?Wt(e):e),r}},{key:"prependTo",value:function(t,e){var n=qt(t,this.win.document),r=this.createCursor(n,"beginning");return r.insertBefore("string"==typeof e?Wt(e):e),r}},{key:"getSelection",value:function(t){var e=this.dispatcher.selectionWatcher.getFreshSelection();if(!t||!e)return e;var n=e.range;return null!=t&&t.isConnected&&function(t,e){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}(t,n)?e:void 0}},{key:"setupHighlighting",value:function(t){return this.highlighting=new Eo(this,t),this}},{key:"setupSpellcheck",value:function(t){var e,n=this;t.markerNode&&(e=t.markerNode.outerHTML),this.setupHighlighting({throttle:t.throttle,spellcheck:{marker:e,spellcheckService:t.spellcheckService}}),this.spellcheck={checkSpelling:function(t){n.highlighting.highlight(t)}}}},{key:"highlight",value:function(t){var e=t.editableHost,n=t.text,r=t.highlightId,i=t.textRange,a=t.raiseEvents,s=t.type,u=void 0===s?"comment":s;return i?"number"!=typeof i.start||"number"!=typeof i.end?(o("Error in Editable.highlight: You passed a textRange object with invalid keys. Expected shape: { start: Number, end: Number }"),-1):i.start===i.end?(o("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):En.highlightRange(e,n,r,i.start,i.end,a?this.dispatcher:void 0,u):En.highlightText(e,n,r,u,a?this.dispatcher:void 0)}},{key:"getHighlightPositions",value:function(t){var e=t.editableHost,n=t.type;return En.extractHighlightedRanges(e,n)}},{key:"removeHighlight",value:function(t){var e=t.editableHost,n=t.highlightId,r=t.raiseEvents;En.removeHighlight(e,n,r?this.dispatcher:void 0)}},{key:"decorateHighlight",value:function(t){var e=t.editableHost,n=t.highlightId,r=t.addCssClass,i=t.removeCssClass;En.updateHighlight(e,n,r,i)}},{key:"getCssHighlightText",value:function(t){return Ct(t.editableHost).text}},{key:"setCssHighlight",value:function(t){var e=t.name,n=t.ranges;!function(t){var e,n=t.name,r=t.ranges,i=void 0===r?[]:r,o=t.win,a=void 0===o?window:o,s=new Map,u=ft(i);try{for(u.s();!(e=u.n()).done;){var c=e.value,l=c.editableHost,f=c.start,h=c.end,d=s.get(l);d?d.push({start:f,end:h}):s.set(l,[{start:f,end:h}])}}catch(t){u.e(t)}finally{u.f()}if(!s.size)return St({name:n,win:a});var v=vt.get(a);v||vt.set(a,v=new Map),v.set(n,s),kt({name:n,hosts:s,win:a})}({name:e,ranges:void 0===n?[]:n,win:this.win})}},{key:"deleteCssHighlight",value:function(t){St({name:t.name,win:this.win})}},{key:"replaceCssHighlight",value:function(t){var e=t.editableHost,n=t.start,r=t.end,i=t.text,o=wt({editableHost:e,start:n,end:r,win:this.win});return!!o&&(new In(e,o).insertCharacter(i).triggerChange(),!0)}},{key:"getCssHighlightRects",value:function(t){return function(t){var e=t.win,n=void 0===e?window:e,r=wt({editableHost:t.editableHost,start:t.start,end:t.end,win:n});if(r){var i=r.getBoundingClientRect(),o=Array.from(r.getClientRects()),a=st(n),s=a.x,u=a.y;return{bounding:Tt(i,s,u),rects:o.map(function(t){return Tt(t,s,u)})}}}({editableHost:t.editableHost,start:t.start,end:t.end,win:this.win})}},{key:"getCssHighlightCursorOffset",value:function(t){var e=t.editableHost,n=this.getSelection(e);if(null!=n&&n.isCursor){var r=n.range;return function(t){for(var e,n=t.editableHost,r=t.container,i=t.containerOffset,o=r.nodeType===f?r.childNodes[i]:void 0,a=Ct(n),s=a.text,u=a.leading,c=function(t){return Math.min(Math.max(t-u,0),s.length)},l=new y(n),d=0;e=l.getNext();){if(e===o)return c(d);if(e.nodeType!==f||"BR"!==e.nodeName){if(e.nodeType===h&&""!==e.data){if(e===r)return c(d+mt(e.data.slice(0,i)).length);d+=mt(e.data).length}}else d+=1}if(!o&&r.nodeType===f)return c(d)}({editableHost:e,container:r.startContainer,containerOffset:r.startOffset})}}},{key:"on",value:function(t,e){return this.dispatcher.on(t,e),this}},{key:"off",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.dispatcher.off.apply(this.dispatcher,e),this}},{key:"unload",value:function(){return this.dispatcher.unload(),this}},{key:"findClosestCursorOffset",value:function(t){var e=t.element,n=t.origCoordinates,r=t.requiredOnFirstLine,i=void 0!==r&&r,o=t.requiredOnLastLine;return function(t){var e=t.host,n=t.requiredOnFirstLine,r=t.requiredOnLastLine,i=t.positionX,o=e.ownerDocument.createRange();o.selectNodeContents(e);var a=o.getBoundingClientRect(),s=Oo(e).reduce(function(t,e){return t+e.textContent.length},0),u=Oo(e);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=Ro({textNodes:u,offset:l.currentOffset}).getBoundingClientRect();c=Math.abs(d.left-i),n&&a.top!==d.top?jo(l):r&&a.bottom!==d.bottom?_o(l):i<d.left?jo(l):_o(l)}var v=Ro({textNodes:u,offset:l.currentOffset}).getBoundingClientRect(),p=Math.abs(v.left-i);return p<c&&(c=p,f=l.currentOffset),{distance:c,offset:f,wasFound:!0}}({host:e,requiredOnFirstLine:i,requiredOnLastLine:void 0!==o&&o,positionX:this.dispatcher.switchContext?this.dispatcher.switchContext.positionX:n.left})}}],n=[{key:"getGlobalConfig",value:function(){return i}},{key:"globalConfig",value:function(t){Object.assign(i,t),Je(i)}}],e&&Po(t.prototype,e),n&&Po(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();return Ho.parser=n,Ho.content=r,["focus","blur","flow","selection","cursor","newline","insert","split","merge","empty","change","switch","move","clipboard","paste","spellcheckUpdated","selectToBoundary"].forEach(function(t){Ho.prototype[t]=function(e){return this.on(t,e)}}),e=e.Editable,e})());
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Editable=e():t.Editable=e()}(self,()=>(()=>{"use strict";const t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})}};t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),t.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),t.r=t=>{Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let e={};t.d(e,{Editable:()=>Hi});var n={};t.r(n),t.d(n,{getHost:()=>R,getNodeIndex:()=>I,isBeginningOfHost:()=>V,isDocumentFragmentWithoutChildren:()=>Y,isEndOfHost:()=>W,isEndOffset:()=>$,isInlineElement:()=>J,isLinebreak:()=>H,isSameNode:()=>Q,isStartOffset:()=>U,isTextEndOfHost:()=>z,isTextEndOffset:()=>K,isVoid:()=>M,isVoidTextNode:()=>L,isWhitespaceOnly:()=>P,lastChild:()=>X,lastOffsetWithContent:()=>q,latestChild:()=>G});var r={};t.r(r),t.d(r,{adoptElement:()=>Wt,areSameAttributes:()=>Yt,cleanInternals:()=>Pt,cloneRangeContents:()=>Ut,containsString:()=>ye,createFragmentFromString:()=>Vt,deleteCharacter:()=>pe,expandTo:()=>ue,extractContent:()=>Ht,forceWrap:()=>ae,getAncestorTags:()=>Qt,getContainedTags:()=>Zt,getInnerHtmlOfFragment:()=>qt,getInnerTags:()=>Jt,getTagNames:()=>te,getTags:()=>Kt,getTagsByName:()=>Xt,getTagsByNameAndAttributes:()=>Gt,insertCharacter:()=>De,isAffectedBy:()=>ee,isExactSelection:()=>re,isWrappable:()=>oe,normalizeTags:()=>Mt,normalizeWhitespace:()=>Lt,nuke:()=>he,nukeElem:()=>de,nukeTag:()=>ge,removeFormatting:()=>fe,removeFormattingElem:()=>le,selectNodeContents:()=>ne,surround:()=>ve,tidyHtml:()=>It,toggleTag:()=>ie,unwrap:()=>ce,unwrapInternalNodes:()=>zt,wrap:()=>se});const u={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 i(){if(!1!==u.logErrors){var e=1===arguments.length?arguments[0]:Array.from(arguments);if(t.g.console)return"function"==typeof console.error?console.error(e):void console.log(e)}}var o=Object.prototype.toString,a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function s(t){return t.replace(/\s+$/,"")}function c(t){return t.replace(/^\s+|\s+$/g,"")}function l(t){return"[object String]"===o.call(t)}var f=1,h=3,d=11;function D(t){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},D(t)}function v(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,p(r.key),r)}}function p(t){var e=function(t){if("object"!=D(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=D(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==D(e)?e:e+""}var y=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.current=this.previous=this.nextNode=this.root=e,this.iteratorFunc=this[n||"getNext"]},(e=[{key:Symbol.iterator,value:function(){return this}},{key:"getNextTextNode",value:function(){for(var t;t=this.getNext();)if(t.nodeType===h&&""!==t.data)return t}},{key:"getPreviousTextNode",value:function(){for(var t;t=this.getPrevious();)if(t.nodeType===h&&""!==t.data)return t}},{key:"next",value:function(){var t=this.iteratorFunc();return t?{value:t}:{done:!0}}},{key:"getNext",value:function(){var t=this.current=this.nextNode,e=this.nextNode=void 0;if(this.current)if((e=t.firstChild)&&"remove"!==t.getAttribute("data-editable"))this.nextNode=e;else for(;t!==this.root&&!(this.nextNode=t.nextSibling);)t=t.parentNode;return this.current}},{key:"getPrevious",value:function(){var t=this.current=this.previous,e=this.previous=void 0;if(this.current)if((e=t.lastChild)&&"remove"!==t.getAttribute("data-editable"))this.previous=e;else for(;t!==this.root&&!(this.previous=t.previousSibling);)t=t.parentNode;return this.current}},{key:"replaceCurrent",value:function(t){this.current=t,this.nextNode=void 0,this.previous=void 0;for(var e=this.current;e!==this.root&&!(this.nextNode=e.nextSibling);)e=e.parentNode}}])&&v(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),g=function(t,e){return"string"==typeof t?Array.from(e.querySelectorAll(t)):t.tagName?[t]:Array.isArray(t)?t:Array.from(t)},m=function(t,e){return"string"==typeof t?e.querySelector(t):t.tagName?t:t[0]?t[0]:t},b=function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return e.innerHTML=t,e.firstElementChild},C=function(t,e){if(t.closest||(t=t.parentNode),t&&t.closest)return t.closest(e)},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()},F=function(t,e,n){for(var r,u=[],i=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:window).document.createNodeIterator(t.commonAncestorContainer,NodeFilter.SHOW_ALL,{acceptNode:function(r){return t.intersectsNode(r)&&e.includes(r.nodeType)&&r!==t.commonAncestorContainer?"function"==typeof n?n(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}},!1);r=i.nextNode();)u.push(r);return u},w=function(t){t.startContainer.compareDocumentPosition(t.endContainer)===Node.DOCUMENT_POSITION_FOLLOWING&&t.setStartBefore(t.endContainer),t.endContainer.compareDocumentPosition(t.startContainer)===Node.DOCUMENT_POSITION_PRECEDING&&t.setEndAfter(t.startContainer)},S=function(t,e){var n=document.createRange();n.selectNodeContents(e);var r=t.compareBoundaryPoints(Range.START_TO_START,n),u=t.compareBoundaryPoints(Range.END_TO_END,n);return r<=0&&u>=0},B=function(t){return t&&(t.nodeType===Node.TEXT_NODE||t.nodeType===Node.COMMENT_NODE)},k=function(t,e){return t.splitText(e)},T=function(t){var e=t.startContainer,n=t.startOffset,r=t.endContainer,u=t.endOffset;if(B(r)&&u>0&&u<r.length&&k(r,u),B(e)&&n>0&&n<e.length){var i=k(e,n);t.setStart(i,0)}},x=function(t,e){var n=t.cloneRange();n.setStart(e,0),n.setEnd(t.startContainer,t.startOffset);var r=t.toString().replace(/\uFEFF/g,""),u=n.toString().length;return{start:u,end:u+r.length,text:r}},O=function(t,e){return t.startContainer===e.startContainer&&t.startOffset===e.startOffset&&t.endContainer===e.endContainer&&t.endOffset===e.endOffset};function N(t){var e=t.root,n=t.startContainer,r=t.startOffset,u=t.whitespacesOnTheLeft;if(n.nodeType!==h)return N({root:e,startContainer:n.childNodes[r],startOffset:0,whitespacesOnTheLeft:u});var i=r+u;if(n.length>i)return[n,i];var o=new y(e);o.nextNode=n,o.getNextTextNode();var a=o.getNextTextNode();if(!a){var s=o.getPreviousTextNode();return[s,s.length]}return N({root:e,startContainer:a,startOffset:0,whitespacesOnTheLeft:i-n.length})}function j(t){var e=t.root,n=t.endContainer,r=t.endOffset,u=t.whitespacesOnTheRight;if(n.nodeType!==h){var i=!n.childNodes[r-1],o=i?n.childNodes[r]:n.childNodes[r-1],a=0;return i||(a=o.nodeType===h?o.length:o.childNodes.length),j({root:e,endContainer:o,endOffset:a,whitespacesOnTheRight:u})}var s=r-u;if(s>0)return[n,s];var c=new y(e);c.previous=n,c.getPreviousTextNode();var l=c.getPreviousTextNode();return l?j({root:e,endContainer:l,endOffset:l.length,whitespacesOnTheRight:u-r}):[c.getNextTextNode(),0]}function _(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function R(t){return t=t.jquery?t[0]:t,C(t,".".concat(u.editableClass))}function I(t){for(var e=0;null!==(t=t.previousSibling);)e++;return e}function M(t){var e,n=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return _(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,u=function(){};return{s:u,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:u}}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 i,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}(t.childNodes);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(r.nodeType===h&&!L(r))return!1;if(r.nodeType===f)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}function L(t){return t.nodeType===h&&!t.nodeValue}function P(t){return t.nodeType===h&&0===q(t)}function H(t){return t.nodeType===f&&"BR"===t.tagName}function q(t){if(t.nodeType===h)return s(t.nodeValue).length;var e=0;return Array.from(t.childNodes).reverse().every(function(t,n,r){return!(!P(t)&&!H(t)&&(e=r.length-n,1))}),e}function V(t,e,n){if(e===t)return U(e,n);if(U(e,n)){var r=I(e);return V(t,e.parentNode,r)}return!1}function W(t,e,n){if(e===t)return $(e,n);if($(e,n)){var r=I(e)+1;return W(t,e.parentNode,r)}return!1}function U(t,e){return t.nodeType===h?0===e:0===t.childNodes.length||1===t.childNodes.length&&t.firstChild.nodeType===f&&"remove"===t.firstChild.getAttribute("data-editable")||t.childNodes[e]===t.firstChild}function $(t,e){return t.nodeType===h?e===t.length:0===t.childNodes.length||e>0&&t.childNodes[e-1]===t.lastChild}function z(t,e,n){if(e===t)return K(e,n);if(K(e,n)){var r=I(e)+1;return z(t,e.parentNode,r)}return!1}function K(t,e){return t.nodeType===h?e>=s(t.nodeValue).length:0===t.childNodes.length||e>=q(t)}function Q(t,e){var n,r,u;if(t.nodeType!==e.nodeType)return!1;if(t.nodeName!==e.nodeName)return!1;for(n=0,r=t.attributes.length;n<r;n++)if(u=t.attributes[n],e.getAttribute(u.name)!==u.value)return!1;return!0}function X(t){return t.lastChild?X(t.lastChild):t}function G(t){return console.warn("Editable.js: Using obsolete function parser.latestCild(), use lastChild() instead"),X(t)}function Y(t){return t&&t.nodeType===d&&0===t.childNodes.length}function J(t,e){switch((e.currentStyle||t.getComputedStyle(e,"")).display){case"inline":case"inline-block":return!0;default:return!1}}var Z=0,tt="\ufeff";function et(t,e){var n=t.commonAncestorContainer;if(3===n.nodeType)return!1;var r=e.parentElement;return(null==r?void 0:r.parentElement)===n}function nt(t,e){var n=t.commonAncestorContainer;n.ownerDocument||i("Cannot save range: range is empty");var r=n.ownerDocument.defaultView.document,u=r.createElement("span");u.id="editable-range-boundary-".concat(++Z),u.setAttribute("data-editable","remove"),u.style.lineHeight="0",u.style.display="none",u.appendChild(r.createTextNode(tt));var o=e&&et(t,t.startContainer),a=!e&&et(t,t.endContainer);if(o){var s=t.startContainer.parentElement;s.parentElement.insertBefore(u,s)}else if(a){var c=t.endContainer.parentElement;c.parentElement.insertBefore(u,c.nextSibling)}else{var l=t.cloneRange();l.collapse(e),l.insertNode(u)}return u}function rt(t,e,n,r){var u=ot(t,n);if(!u)return console.log("Marker element has been removed. Cannot restore selection.");e[r?"setStartBefore":"setEndBefore"](u),u.remove()}function ut(t){var e,n,r;return t.collapsed?e={markerId:(r=nt(t,!1)).id,collapsed:!0}:(r=nt(t,!1),e={startMarkerId:(n=nt(t,!0)).id,endMarkerId:r.id,collapsed:!1}),t.collapsed?(t.setStartBefore(r),t.collapse(!0)):(t.setEndBefore(r),t.setStartAfter(n)),e}function it(t,e){if(!e.restored){var n=A();if(e.collapsed){var r=ot(t,e.markerId);if(r){r.style.display="inline";var u=r.previousSibling;u&&u.nodeType===h?(r.remove(),n.setStart(u,u.length)):(n.setStartBefore(r),n.collapse(!0),r.remove())}else console.log("Marker element has been removed. Cannot restore selection.")}else rt(t,n,e.startMarkerId,!0),rt(t,n,e.endMarkerId,!1);return w(n),n}}function ot(t,e){return t.querySelector("#".concat(e))}function at(t){return{x:void 0!==t.pageXOffset?t.pageXOffset:(t.document.documentElement||t.document.body.parentNode||t.document.body).scrollLeft,y:void 0!==t.pageYOffset?t.pageYOffset:(t.document.documentElement||t.document.body.parentNode||t.document.body).scrollTop}}function st(t,e){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},st(t,e)}function ct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(ct=function(){return!!t})()}function lt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,u,i,o,a=[],s=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(a.push(r.value),a.length!==e);s=!0);}catch(t){c=!0,u=t}finally{try{if(!s&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw u}}return a}}(t,e)||ht(t,e)||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 ft(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=ht(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,u=function(){};return{s:u,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:u}}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 i,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function ht(t,e){if(t){if("string"==typeof t)return dt(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?dt(t,e):void 0}}function dt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var Dt=new WeakMap,vt=/[\uFEFF\u200B]/g,pt=function(t){return"\ufeff"===t||"​"===t},yt=function(t){return t.indexOf("\ufeff")>=0||t.indexOf("​")>=0},gt=function(t){return yt(t)?t.replace(vt,""):t};function mt(t){var e,n=t.editableHost,r=t.win,u=void 0===r?null==n||null===(e=n.ownerDocument)||void 0===e?void 0:e.defaultView:r,i=Dt.get(u);if(null!=i&&i.size){var o,a=ft(i);try{for(a.s();!(o=a.n()).done;){var s=lt(o.value,2),c=s[0],l=s[1];if(l.has(n)){var f,h=ft(l.keys());try{for(h.s();!(f=h.n()).done;){var d=f.value;null!=d&&d.isConnected||l.delete(d)}}catch(t){h.e(t)}finally{h.f()}l.size?At({name:c,hosts:l,win:u}):Ct({name:c,win:u})}}}catch(t){a.e(t)}finally{a.f()}}}function bt(t){var e=t.editableHost,n=t.start,r=t.end,u=t.win,i=void 0===u?window:u;return Ft({segments:Et(e).segments,start:n,end:r,win:i})}function Ct(t){var e,n=t.name,r=t.win,u=void 0===r?window:r;null===(e=Dt.get(u))||void 0===e||e.delete(n),u.CSS.highlights.delete(n)}function At(t){var e,n=t.name,r=t.hosts,u=t.win,i=[],o=ft(r);try{for(o.s();!(e=o.n()).done;){var a=lt(e.value,2),s=a[0],c=a[1],l=Et(s).segments;if(l.length){var f,h=ft(c);try{for(h.s();!(f=h.n()).done;){var d=f.value,D=Ft({segments:l,start:d.start,end:d.end,win:u});D&&i.push(D)}}catch(t){h.e(t)}finally{h.f()}}}}catch(t){o.e(t)}finally{o.f()}if(!i.length)return u.CSS.highlights.delete(n);u.CSS.highlights.set(n,function(t,e,n){if(ct())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var u=new(t.bind.apply(t,r));return n&&st(u,n.prototype),u}(u.Highlight,i))}function Et(t){var e,n=[],r="",u=function(t,e,u){n.push({node:t,nodeOffset:e,start:r.length,end:r.length+u.length}),r+=u},i=ft(new y(t));try{for(i.s();!(e=i.n()).done;){var o=e.value;if(o.nodeType!==f||"BR"!==o.nodeName){if(o.nodeType===h&&""!==o.data){var a=o.data;if(yt(a)){for(var s=0,c=0,l=0;l<a.length;l++)pt(a[l])?(c&&u(o,s,a.slice(s,s+c)),c=0):(0===c&&(s=l),c+=1);c&&u(o,s,a.slice(s,s+c))}else u(o,0,a)}}else r+="\n"}}catch(t){i.e(t)}finally{i.f()}for(var d=r.length-r.trimStart().length,D=r.trimEnd().length,v=[],p=0,g=n;p<g.length;p++){var m=g[p],b=Math.max(m.start,d),C=Math.min(m.end,D);b>=C||v.push({node:m.node,nodeOffset:m.nodeOffset+(b-m.start),start:b-d,end:C-d})}return{text:r.slice(d,Math.max(d,D)),leading:d,segments:v}}function Ft(t){var e=t.segments,n=t.start,r=t.end,u=t.win,i=wt(e,n,!1),o=wt(e,r,!0);if(i&&o){var a=A(u);return a.setStart(i.node,i.offset),a.setEnd(o.node,o.offset),a}}function wt(t,e,n){for(var r=0,u=t.length;r<u;){var i=r+u>>1,o=t[i].end;(n?o>=e:o>e)?u=i:r=i+1}var a=t[r];if(a)return{node:a.node,offset:a.nodeOffset+Math.max(0,e-a.start)}}function St(t,e,n){return{top:t.top+n,bottom:t.bottom+n,left:t.left+e,right:t.right+e,width:t.width,height:t.height}}function Bt(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return kt(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?kt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,u=function(){};return{s:u,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:u}}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 i,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function kt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Tt(t,e,n){return e=ut(e),n(),it(t,e)}var xt=/\u200B/g,Ot=/\uFEFF/g,Nt=/[^\S ]/g,jt=/^\s+$/,_t=/^\s+/,Rt=/\s+$/;function It(t){Mt(t)}function Mt(t){var e=document.createDocumentFragment();$t(t,"firstChild"),$t(t,"lastChild");var n,r=Bt(t.childNodes);try{for(r.s();!(n=r.n()).done;){var u=n.value;if("BR"===u.nodeName||u.textContent){if(u.nodeType===f&&"BR"!==u.nodeName){for(var i=u;null!==(i=i.nextSibling)&&Q(i,u);){var o,a=Bt(i.childNodes);try{for(a.s();!(o=a.n()).done;){var s=o.value;u.appendChild(s.cloneNode(!0))}}catch(t){a.e(t)}finally{a.f()}i.remove()}Mt(u)}e.appendChild(u.cloneNode(!0))}}}catch(t){r.e(t)}finally{r.f()}for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(e)}function Lt(t){return t.replace(Nt," ")}function Pt(t){t.innerHTML=Ht(t,!0),mt({editableHost:t})}function Ht(t,e){var n=(t.nodeType===d?qt(t):t.innerHTML).replace(Ot,"").replace(xt,""),r=document.createElement("div");return r.innerHTML=n,zt(r,e),$t(r,"firstChild"),$t(r,"lastChild"),r.innerHTML}function qt(t){var e=t.cloneNode(!0),n=document.createElement("div");return n.appendChild(e),n.innerHTML}function Vt(t){var e=document.createElement("div");e.innerHTML=t;for(var n=document.createDocumentFragment();e.firstChild;)n.appendChild(e.firstChild);return n}function Wt(t,e){return t.ownerDocument!==e?e.adoptNode(t):t}function Ut(t){for(var e=t.cloneContents().childNodes[0],n=document.createDocumentFragment();e.childNodes.length;)n.appendChild(e.childNodes[0]);return n}function $t(t,e){for(var n,r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];r=t[e];)if(r.nodeType===h){if(!jt.test(r.textContent))break;t.removeChild(r)}else{if("BR"!==r.nodeName){r[e]&&$t(r,e,!1);break}r.remove()}i&&(null===(n=r=t[e])||void 0===n?void 0:n.nodeType)===h&&u.trimLeadingAndTrailingWhitespaces&&(r.textContent=r.textContent.replace(e.startsWith("last")?Rt:_t,""))}function zt(t,e){for(;t;){var n=t.nextSibling;if(t.nodeType===f){var r=t.getAttribute("data-editable");t.firstChild&&zt(t.firstChild,e),("remove"===r||"ui-remove"===r&&!e)&&t.remove(),("unwrap"===r||"ui-unwrap"===r&&!e)&&ce(t),t=n}else t=n}}function Kt(t,e,n){var r=Jt(e,n),u=Qt(t,e,n);return r.concat(u)}function Qt(t,e,n){for(var r=[],u=e.commonAncestorContainer;u!==t;)n&&!n(u)||r.push(u),u=u.parentNode;return r}function Xt(t,e,n){return Kt(t,e,function(t){return t.nodeName.toUpperCase()===n.toUpperCase()})}function Gt(t,e,n){return Kt(t,e,function(t){return t.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&Yt(t.attributes,n.attributes)})}function Yt(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++){var r=e[t[n].name];if(!r||r.value!==t[n].value)return!1}return!0}function Jt(t,e){return F(t,[f],e)}function Zt(t,e){return F(t,[f],e).filter(function(e){return S(t,e)})}function te(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return t.nodeName})}function ee(t,e,n){return Kt(t,e).some(function(t){return t.nodeName===n.toUpperCase()})}function ne(t){var e=A();return e.selectNodeContents(t),e}function re(t,e,n){var r,u,i=A();if(i.selectNodeContents(e),u=i,-1!==(r=t).compareBoundaryPoints(Range.END_TO_START,u)||-1!==u.compareBoundaryPoints(Range.END_TO_START,r))return!1;var o=t.toString(),a=(e.jquery?e[0]:e).textContent;return n&&(o=c(o),a=c(a)),""!==o&&o===a}function ue(t,e,n){return e.selectNodeContents(n),e}function ie(t,e,n){var r=Gt(t,e,n);return 1===r.length&&re(e,r[0],"visible")?le(t,e,n):ae(t,e,n)}function oe(t){return function(t){if(!t||!t.startContainer||!t.endContainer)return!1;if(t.startContainer===t.endContainer)return!0;for(var e,n=function(t){var e=t,n=null;return{next:function(){if(!e)return null;if(e.firstChild&&n!==e.firstChild)n=e,e=e.firstChild;else if(e.nextSibling)n=e,e=e.nextSibling;else{for(var r=e.parentNode;r&&r!==t;){if(r.nextSibling){n=e=r.nextSibling;break}r=r.parentNode}r&&r!==t||(n=e=null)}return e}}}(t.commonAncestorContainer),r=!1;e=n.next();)if(e.nodeType===Node.ELEMENT_NODE&&!me(e,t)){r=!0;break}return!r}(t)}function ae(t,e,n){var r=Tt(t,e,function(){de(t,e,n)});return oe(r)||(r=Tt(t,r,function(){he(t,r)})),se(r,n),mt({editableHost:t}),r}function se(t,e){oe(t)?("string"==typeof e&&(e=b(e)),t.surroundContents(e)):console.log("content.wrap(): can not surround range")}function ce(t){for(var e=(t=t.jquery?t[0]:t).parentNode;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}function le(t,e,n){var r=Tt(t,e,function(){de(t,e,n)});return mt({editableHost:t}),r}function fe(t,e,n){var r=Tt(t,e,function(){he(t,e,n)});return mt({editableHost:t}),r}function he(t,e,n){Kt(t,e).forEach(function(t){"BR"===t.nodeName.toUpperCase()||n&&!t.matches(n)||ce(t)})}function de(t,e,n){Kt(t,e).forEach(function(t){"BR"!==t.nodeName.toUpperCase()&&(!n||t.nodeName.toUpperCase()===n.nodeName.toUpperCase()&&Yt(t.attributes,n.attributes))&&ce(t)})}function De(t,e,n){var r=document.createTextNode(e),u=t.cloneRange();u.collapse(n),u.insertNode(r),t[n?"setStartBefore":"setEndAfter"](r),w(t)}function ve(t,e,n,r){return De(e,r||n,!1),De(e,n,!0),e}function pe(t,e,n){if(!ye(e,n))return e;window.getSelection().rangeCount>0&&T(e);var r=Tt(t,e,function(){F(e,[h],function(t){return t.nodeValue.indexOf(n)>=0}).forEach(function(t){t.nodeValue=t.nodeValue.replaceAll(n,"")})});return w(r),r}function ye(t,e){return t.toString().indexOf(e)>=0}function ge(t,e,n){Kt(t,e).forEach(function(t){t.nodeName.toUpperCase()===n.toUpperCase()&&ce(t)})}function me(t,e){var n=document.createRange();return n.selectNodeContents(t),e.compareBoundaryPoints(Range.START_TO_START,n)<=0&&e.compareBoundaryPoints(Range.END_TO_END,n)>=0}var be=1,Ce={},Ae=Be("nextElementSibling"),Ee=Be("previousElementSibling");function Fe(t,e){var n=e.normalize,r=e.plainText,i=e.shouldSpellcheck;!function(t){t.hasAttribute("data-editable")||(t.setAttribute("data-editable","id-".concat(be)),be+=1)}(t),t.setAttribute("contenteditable",!0),t.setAttribute("spellcheck",Boolean(i)),t.setAttribute("data-plaintext",Boolean(r)),t.classList.remove(u.editableDisabledClass),t.classList.add(u.editableClass),n&&It(t)}function we(t){t.removeAttribute("contenteditable"),t.removeAttribute("spellcheck"),t.removeAttribute("data-plaintext"),function(t){if(t.hasAttribute("data-editable")){var e=t.getAttribute("data-editable");Ce[e]=void 0}}(t),t.classList.remove(u.editableClass),t.classList.add(u.editableDisabledClass)}function Se(t){return"true"===t.getAttribute("data-plaintext")}function Be(t){return function(e){var n=e[t];return n&&n.getAttribute("contenteditable")?n:null}}function ke(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var Te,xe,Oe,Ne,je,_e,Re,Ie,Me,Le=[["«","»"],["»","«"],['"','"'],["“","”"],["”","”"],["“","“"],["„","“"]],Pe=[["‘","’"],["‹","›"],["‚","‘"],["’","’"],["›","‹"],["'","'"],["‘","’"]],He=["’","'"],qe=/([‘’‹›‚'«»"“”„])(?![^<]*?>)/g,Ve=/\s|[>\-–—«»”"“„]/,We=/\s|[<\-–—«»”"“‘’‹›'.;?:,]/;function Ue(t,e){(Te=e||{}).quotes=Te.quotes||[void 0,void 0],Te.singleQuotes=Te.singleQuotes||[void 0,void 0];var n=function(t){return(e=t.matchAll(qe),function(t){if(Array.isArray(t))return ke(t)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return ke(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ke(t,e):void 0}}(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.")}()).map(function(e){var n=e.index;return{char:e[1],before:n>0?t[n-1]:"",after:n+1<t.length?t[n+1]:""}});var e}(t);return n.length>0?($e(n,0),function(t,e){var n=0;return t.replace(qe,function(t){var r=e[n].replace||e[n].char;return n+=1,r})}(t,n)):t}function $e(t,e){for(;e<t.length;){var n=ze(t,e);if(n){if(t[e].replace="double"===n.type?Te.quotes[0]:Te.singleQuotes[0],t[n.position].replace="double"===n.type?Te.quotes[1]:Te.singleQuotes[1],n.position!==e+1){var r=t.slice(e+1,n.position);r&&$e(r,0)}e=n.position+1}else t[e].replace=Qe(t[e].char),e+=1}}function ze(t,e){if(e!==t.length-1){var n=t[e],r=n.char;if(!n.before||Ve.test(n.before))for(var u=Ke(r,Pe),i=Ke(r,Le),o=e+1;o<t.length;o++)if(t[o].after&&We.test(t[o].after)||!t[o].after){if(u.includes(t[o].char))return{position:o,type:"single"};if(i.includes(t[o].char))return{position:o,type:"double"}}}}function Ke(t,e){return e.filter(function(e){return e[0]===t}).map(function(t){return t[1]})}function Qe(t){if(He.includes(t))return Te.apostrophe}var Xe,Ge=/^\s*$/,Ye="\x3c!-- BLOCK --\x3e";function Je(t){var e=t.pastedHtmlRules;xe=e.allowedElements||{},Oe=e.allowedPlainTextElements||{},Ne=e.requiredAttributes||{},je=e.transformElements||{},Me=e.blacklistedElements||[],Xe=e.keepInternalRelativeLinks||!1,Re=e.replaceQuotes||{},_e={},e.blockLevelElements.forEach(function(t){_e[t]=!0}),Ie={},e.splitIntoBlocks.forEach(function(t){Ie[t]=!0})}function Ze(t,e,n){var r=t.ownerDocument;t.setAttribute(u.pastingAttribute,!0),e.isSelection&&(e=e.deleteExactSurroundingTags().deleteContainedTags().deleteContent());var i=r.createElement("div");i.innerHTML=n;var o=function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).plainText,n=void 0!==e&&e;return tn(t,{allowedElements:n?Oe:xe,keepInternalRelativeLinks:!n&&Xe}).split(Ye).map(function(t){return c((e=t,Re.quotes||Re.singleQuotes||Re.apostrophe?Ue(e,Re):e).replace(/\n/g," ").replace(/ {2,}/g," ").replace(/(.)\u00A0/g,function(t,e){return e+(/[\u0020]/.test(e)?" ":" ")}));var e}).filter(function(t){return!Ge.test(t)})}(i,{plainText:Se(t)});return t.removeAttribute(u.pastingAttribute),{blocks:o,cursor:e}}function tn(t,e){return Array.from(t.childNodes).reduce(function(t,n){if(-1!==Me.indexOf(n.nodeName.toLowerCase()))return"";if(e.keepInternalRelativeLinks&&"A"===n.nodeName&&n.href){var r=n.getAttribute("href").replace(window.location.origin,"");n.setAttribute("href",r)}return n.nodeType===f?t+function(t,e,n){var r=t.nodeName.toLowerCase();if(function(t,e,n){return n.allowedElements[t]&&function(t,e){var n=Ne[t];return!n||!n.some(function(t){return!e.getAttribute(t)})}(t,e)}(r=function(t){return je[t]||t}(r),t,n)){var u=function(t,e){return Array.from(e.attributes).reduce(function(e,n){var r,u=n.name,i=n.value;return null!==(r=xe[t])&&void 0!==r&&r[u]&&i?"".concat(e," ").concat(u,'="').concat(i,'"'):e},"")}(r,t);return"br"===r?"<".concat(r+u,">"):Ge.test(e)?e:"<".concat(r+u,">").concat(e,"</").concat(r,">")}return Ie[r]?Ye+e+Ye:_e[r]?"".concat(e," "):e}(n,tn(n,e),e):n.nodeType===h?t+n.nodeValue.replace(/[&<>]/g,function(t){return a[t]}):t},"")}Je(u),document.documentElement.contentEditable;var en=/(apple)?webkit\/537\.36/i.test(window.navigator.userAgent),nn=/(apple)?webkit/i.test(window.navigator.userAgent),rn=!en&&nn,un=function(t){var e=t,n=e.onselectionchange;if(void 0!==n)try{return e.onselectionchange=0,null===e.onselectionchange}catch(t){}finally{e.onselectionchange=n}return!1}(document),on=!!rn;function an(t,e){var n=function(t){var e={};function n(t,n){t.split(" ").forEach(function(t){e[t]=e[t]||[],e[t].unshift(n)})}return{on:function(t,e){if(2===arguments.length)n(t,e);else if(1===arguments.length)for(var r in t)n(r,t[r]);return this},off:function(t,n){2===arguments.length?function(t,n){var r=e[t];if(r){var u=r.indexOf(n);u<0||r.splice(u,1)}}(t,n):1===arguments.length?e[t]=[]:e={}},notify:function(n,r){var u=Array.from(arguments);t?(r=n,n=t,u.splice(0,1)):u.splice(0,2),this.switchContext&&r!==this.switchContext.events.shift()&&(this.switchContext=void 0);var i=e[r];i&&i.every(function(t){return!1!==t.apply(n,u)})}}}(e);t.on=n.on,t.off=n.off,t.notify=n.notify}function sn(t){return sn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},sn(t)}function cn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ln(r.key),r)}}function ln(t){var e=function(t){if("object"!=sn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=sn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sn(e)?e:e+""}var fn=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.setHost(e),this.range=n,this.isCursor=!0}return e=t,n=[{key:"getTags",value:function(t){return Kt(this.host,this.range,t)}},{key:"getTagNames",value:function(t){return te(this.getTags(t))}},{key:"getTagsByName",value:function(t){return Xt(this.host,this.range,t)}},{key:"getInnerTags",value:function(t){return Jt(this.range,t)}},{key:"getContainedTags",value:function(t){return Zt(this.range,t)}},{key:"getAncestorTags",value:function(t){return Qt(this.host,this.range,t)}},{key:"isAtEnd",value:function(){return W(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtTextEnd",value:function(){return z(this.host,this.range.endContainer,this.range.endOffset)}},{key:"isAtLastLine",value:function(){var t=this.win.document.createRange();t.selectNodeContents(this.host),t.collapse(!1);var e=hn(t,this.win),n=hn(this.range,this.win);return dn(e.bottom,n.bottom)}},{key:"isAtFirstLine",value:function(){var t=this.win.document.createRange();t.selectNodeContents(this.host),t.collapse(!0);var e=hn(t,this.win),n=hn(this.range,this.win);return dn(e.top,n.top)}},{key:"isAtBeginning",value:function(){return V(this.host,this.range.startContainer,this.range.startOffset)}},{key:"insertBefore",value:function(t){if(l(t)&&(t=Vt(t)),!Y(t)){var e=t=this.adoptElement(t);if(t.nodeType===d){var n=t.childNodes.length-1;e=t.childNodes[n]}this.range.insertNode(t),this.range.setStartAfter(e),this.range.setEndAfter(e),this.host.normalize()}}},{key:"insertAfter",value:function(t){if(l(t)&&(t=Vt(t)),!Y(t)){t=this.adoptElement(t);var e=this.range.cloneRange();e.setStart(e.endContainer,e.endOffset),e.collapse(!0),e.insertNode(t),this.host.normalize()}}},{key:"setSelection",value:function(){this.setVisibleSelection()}},{key:"setVisibleSelection",value:function(){if(this.win.document.activeElement!==this.host){var t=at(this.win),e=t.x,n=t.y;this.win.scrollTo(e,n)}var r=E(this.win);r.removeAllRanges(),r.addRange(this.range)}},{key:"before",value:function(){var t=this.range.cloneRange();return t.collapse(!0),t.setStartBefore(this.host),Ut(t)}},{key:"textBefore",value:function(){var t=this.range.cloneRange();return t.collapse(!0),t.setStartBefore(this.host),t.toString()}},{key:"beforeHtml",value:function(){return qt(this.before())}},{key:"after",value:function(){var t=this.range.cloneRange();return t.collapse(!1),t.setEndAfter(this.host),Ut(t)}},{key:"textAfter",value:function(){var t=this.range.cloneRange();return t.collapse(!1),t.setEndAfter(this.host),t.toString()}},{key:"afterHtml",value:function(){return qt(this.after())}},{key:"getBoundingClientRect",value:function(){return this.range.getBoundingClientRect()}},{key:"getCoordinates",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"absolute",e=this.range.getBoundingClientRect();if("fixed"===t)return e;var n=at(this.win),r=n.x,u=n.y;return{top:e.top+u,bottom:e.bottom+u,left:e.left+r,right:e.right+r,height:e.height,width:e.width}}},{key:"moveBefore",value:function(e){if(this.updateHost(e),this.range.setStartBefore(e),this.range.setEndBefore(e),this.isSelection)return new t(this.host,this.range)}},{key:"moveAfter",value:function(e){if(this.updateHost(e),this.range.setStartAfter(e),this.range.setEndAfter(e),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtBeginning",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(e),this.range.selectNodeContents(e),this.range.collapse(!0),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtEnd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.host;if(this.updateHost(e),this.range.selectNodeContents(e),this.range.collapse(!1),this.isSelection)return new t(this.host,this.range)}},{key:"moveAtTextEnd",value:function(t){return this.moveAtEnd(X(t))}},{key:"setHost",value:function(t){t.jquery&&(t=t[0]),this.host=t,this.win=null==t?window:t.ownerDocument.defaultView}},{key:"updateHost",value:function(t){var e=R(t);e||i("Can not set cursor outside of an editable block"),this.setHost(e)}},{key:"retainVisibleSelection",value:function(t){this.save(),t(),this.restore(),this.setVisibleSelection()}},{key:"save",value:function(){this.savedRangeInfo=ut(this.range),this.savedRangeInfo.host=this.host}},{key:"restore",value:function(){this.savedRangeInfo||i("Could not restore selection"),this.host=this.savedRangeInfo.host,this.range=it(this.host,this.savedRangeInfo),this.savedRangeInfo=void 0}},{key:"equals",value:function(t){return!!(t&&t.host&&t.host.isEqualNode(this.host)&&t.range&&O(t.range,this.range))}},{key:"createElement",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.win.document.createElement(t);for(var r in e){var u=e[r];n.setAttribute(r,u)}return n}},{key:"createTextNode",value:function(t){return this.win.document.createTextNode(t)}},{key:"adoptElement",value:function(t){return Wt(t,this.win.document)}},{key:"triggerChange",value:function(){var t=new Event("formatEditable",{bubbles:!0,cancelable:!1});this.host.dispatchEvent(t)}}],r=[{key:"findHost",value:function(t,e){return C(t,e)}}],n&&cn(e.prototype,n),r&&cn(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function hn(t,e){if(t.startContainer.nodeType!==f)return t.getBoundingClientRect();var n=e.document.createElement("span");n.setAttribute("doc-editable","unwrap"),t.insertNode(n);var r=n.getBoundingClientRect();return n.remove(),r}function dn(t,e){return t===e||Math.abs(t-e)<=2}const Dn={extractText:function(t){var e="";return function(t,e,n){for(var r,u=new y(t);r=u.getNext();)r.nodeType===h&&""!==r.data?n(r.data):e&&r.nodeType===f&&"BR"===r.nodeName&&n("\n")}(t,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],function(t){e+=t}),e},highlightMatches:function(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e&&0!==e.length){t.normalize();for(var r,u,i,o=new y(t),a=0,s=0,c=e[a],l=[];r=o.getNext();)if(r.nodeType===h&&""!==r.data){var d=(i=r).data,D=s+d.length;if(c.startIndex<D&&s<c.endIndex){var v=s<=c.startIndex,p=D>=c.endIndex;v&&(u=c.id||c.startIndex);var g;g=v?c.startIndex-s:0;var m;m=p?c.endIndex-s-g:d.length-g;var b={element:i,text:d.substring(g,g+m),offset:g,length:m,isLastPortion:p,wordId:u};if(l.push(b),p){var C=this.wrapMatch(l,c.marker,c.title);o.replaceCurrent(C),D=s+b.length+b.offset,l=[],(a+=1)<e.length&&(c=e[a])}}s=D}else if(n&&r.nodeType===f&&"BR"===r.nodeName){s+=1;continue}}},wrapMatch:function(t,e,n){var r=this;return t.map(function(t){return r.wrapPortion(t,e,n)}).pop()},wrapPortion:function(t,e,n){var r=A();r.setStart(t.element,t.offset),r.setEnd(t.element,t.offset+t.length);var u=e.cloneNode(!0);if(u.setAttribute("data-word-id",t.wordId),n&&u.setAttribute("title",n),r.surroundContents(u),u.nextSibling){var i=u.nextSibling;i.nodeType===h&&""===i.data&&i.remove()}return u}};function vn(t){return vn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vn(t)}function pn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function yn(t,e,n,r){if(!t||""===t)return[];if(r&&!function(t){try{var e;return!!t&&t instanceof(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView.HTMLElement)}catch(e){return"object"===vn(t)&&1===t.nodeType&&"object"===vn(t.style)&&"object"===vn(t.ownerDocument)}}(r))return[];if(null==e||!e.length)return[];var u,i=("word"===n?bn:gn)(e);return(u=t.matchAll(i),function(t){if(Array.isArray(t))return pn(t)}(u)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(u)||function(t,e){if(t){if("string"==typeof t)return pn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pn(t,e):void 0}}(u)||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.")}()).map(function(t){var e,u;return"word"===n?(e=t.index+t[1].length,u=t[2]):(e=t.index,u=t[0]),{startIndex:e,endIndex:e+u.length,match:u,marker:r}})}function gn(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return Cn(t)}),e="(".concat(t.join("|"),")");return new RegExp(e,"g")}var mn="\\u0041-\\u005A\\u0061-\\u007A\\u0030-\\u0039\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u00FF\\u0100-\\u017F\\u0180-\\u024F";function bn(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return Cn(t)}),e="([^".concat(mn,"]|^)")+"(".concat(t.join("|"),")")+"(?=[^".concat(mn,"]|$)");return new RegExp(e,"g")}function Cn(t){return String(t).replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function An(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return En(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?En(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,u=function(){};return{s:u,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:u}}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 i,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function En(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var Fn={highlightText:function(t,e,n,r,u){if(!this.hasHighlight(t,n)){var i=Dn.extractText(t),o='<span class="highlight-'.concat(r,'"></span>'),a=function(t,e,n){return yn(t,[e],"text",n)}(i,e,Fn.createMarkerNode(o,r,this.win));return a&&a.length?(n&&(a[0].id=n),Dn.highlightMatches(t,a),mt({editableHost:t}),u&&u.notify("change",t),a[0].startIndex):void 0}},highlightRange:function(t,e,n,r,u,i){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"comment";this.hasHighlight(t,n)&&this.removeHighlight(t,n);var a=Dn.extractText(t,!1);if(""===a)return-1;var s=Fn.createMarkerNode('<span class="highlight-'.concat(o,'"></span>'),o,this.win);if(e){var c=document.createElement("div");if(c.innerHTML=e,c.textContent!==a.slice(r,u))return-1}return Dn.highlightMatches(t,[{startIndex:r,endIndex:u,id:n,marker:s}],!1),mt({editableHost:t}),i&&i.notify("change",t),r},updateHighlight:function(t,e,n,r){if(document.documentElement.classList){var u,i=An(t.querySelectorAll('[data-word-id="'.concat(e,'"]')));try{for(i.s();!(u=i.n()).done;){var o=u.value;r&&o.classList.remove(r),n&&o.classList.add(n)}}catch(t){i.e(t)}finally{i.f()}}},removeHighlight:function(t,e,n){var r,u=An(t.querySelectorAll('[data-word-id="'.concat(e,'"]')));try{for(u.s();!(r=u.n()).done;)ce(r.value)}catch(t){u.e(t)}finally{u.f()}t.normalize(),mt({editableHost:t}),n&&n.notify("change",t)},hasHighlight:function(t,e){return!!t.querySelectorAll('[data-word-id="'.concat(e,'"]')).length},extractHighlightedRanges:function(t,e){var n="[data-word-id]";e&&(n+='[data-highlight="'.concat(e,'"]'));var r=t.querySelectorAll(n);if(r.length){var u,i={},o=An(r);try{for(o.s();!(u=o.n()).done;){var a=u.value.getAttribute("data-word-id");i[a]||(i[a]=t.querySelectorAll('[data-word-id="'.concat(a,'"]')))}}catch(t){o.e(t)}finally{o.f()}var s={};for(var c in i){var l=this.extractMarkerNodePosition(t,i[c]);l&&(s[c]=l)}return s}},extractMarkerNodePosition:function(t,e){var n=A();e.length>1?(n.setStartBefore(e[0]),n.setEndAfter(e[e.length-1])):n.selectNode(e[0]);var r=x(n,t);return{start:r.start,end:r.end,text:r.text,nativeRange:n}},cleanupStaleMarkerNodes:function(t,e){var n,r=An(t.querySelectorAll('span[data-highlight="'.concat(e,'"]')));try{for(r.s();!(n=r.n()).done;){var u=n.value;u.textContent.length||u.remove()}}catch(t){r.e(t)}finally{r.f()}},createMarkerNode:function(t,e,n){var r=b(t,n);return r.setAttribute("data-editable","ui-unwrap"),r.setAttribute("data-highlight",e),r}};const wn=Fn;function Sn(t){return Sn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Sn(t)}function Bn(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,u,i,o,a=[],s=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(a.push(r.value),a.length!==e);s=!0);}catch(t){c=!0,u=t}finally{try{if(!s&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw u}}return a}}(t,e)||kn(t,e)||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 kn(t,e){if(t){if("string"==typeof t)return Tn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Tn(t,e):void 0}}function Tn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function xn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,On(r.key),r)}}function On(t){var e=function(t){if("object"!=Sn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Sn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sn(e)?e:e+""}function Nn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Nn=function(){return!!t})()}function jn(t){return jn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},jn(t)}function _n(t,e){return _n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_n(t,e)}var Rn=function(t){function e(){var t;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),delete(t=function(t,e,n){return e=jn(e),function(t,e){if(e&&("object"==Sn(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Nn()?Reflect.construct(e,n||[],jn(t).constructor):e.apply(t,n))}(this,e,arguments)).isCursor,t.isSelection=!0,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_n(t,e)}(e,t),n=e,r=[{key:"text",value:function(){return this.range.toString()}},{key:"html",value:function(){return function(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:window).document.createElement("div");return e.appendChild(t.cloneContents()),e.innerHTML}(this.range)}},{key:"isAllSelected",value:function(){return V(this.host,this.range.startContainer,this.range.startOffset)&&z(this.host,this.range.endContainer,this.range.endOffset)}},{key:"getTextRange",value:function(){return x(this.range,this.host)}},{key:"toString",value:function(){return this.range.toString()}},{key:"isWrappable",value:function(){return oe(this.range)}},{key:"getRects",value:function(){return this.range.getClientRects()}},{key:"link",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t&&(e.href=t);var n=this.createElement(u.linkMarkup.name,u.linkMarkup.attribs);for(var r in e){var i=e[r];void 0!==i&&(null===i?n.removeAttribute(r):n.setAttribute(r,i))}u.linkMarkup.trim&&this.trimRange(),this.forceWrap(n)}},{key:"trimRange",value:function(){var t=this.range.toString(),e=t.search(/\S|$/),n=t.search(/\S[\s]+$/),r=-1===n?0:t.length-(n+1),u=Bn(N({root:this.range.commonAncestorContainer,startContainer:this.range.startContainer,startOffset:this.range.startOffset,whitespacesOnTheLeft:e}),2),i=u[0],o=u[1];this.range.setStart(i,o);var a=Bn(j({root:this.range.commonAncestorContainer,endContainer:this.range.endContainer,endOffset:this.range.endOffset,whitespacesOnTheRight:r}),2),s=a[0],c=a[1];this.range.setEnd(s,c)}},{key:"unlink",value:function(){this.removeFormatting(u.linkMarkup.name)}},{key:"toggleLink",value:function(t,e){var n=this.getTagsByName(u.linkMarkup.name);if(n.length>=1){var r=n[0];this.isExactSelection(r,"visible")?this.unlink():this.expandTo(r)}else this.link(t,e)}},{key:"highlightComment",value:function(t){var e=t.highlightId,n=t.textRange;wn.highlightRange(this.host,e,n.text,n.start,n.end,void 0,"comment")}},{key:"highlight",value:function(t){t.highlightId;var e=this.textBefore(),n=this.text(),r=wn.createMarkerNode('<span class="highlight-comment"></span>',this.win);r.setAttribute("data-match",n);var u={startIndex:e.length,endIndex:e.length+n.length,match:n,marker:r};Dn.highlightMatches(this.host,[u])}},{key:"toggle",value:function(t){Se(this.host)||this.range.collapsed||(t=this.adoptElement(t),this.range=ie(this.host,this.range,t),this.setVisibleSelection())}},{key:"toggleCustom",value:function(t){var e=t.tagName,n=t.attributes,r=t.trim,u=void 0!==r&&r,i=this.createElement(e,n);u&&this.trimRange(),this.toggle(i)}},{key:"makeCustom",value:function(t){var e=t.tagName,n=t.attributes,r=t.trim,u=void 0!==r&&r,i=this.createElement(e,n);u&&this.trimRange(),this.forceWrap(i)}},{key:"makeBold",value:function(){var t=this.createElement(u.boldMarkup.name,u.boldMarkup.attribs);u.boldMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleBold",value:function(){var t=this.createElement(u.boldMarkup.name,u.boldMarkup.attribs);u.boldMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"giveEmphasis",value:function(){var t=this.createElement(u.italicMarkup.name,u.italicMarkup.attribs);u.italicMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleEmphasis",value:function(){var t=this.createElement(u.italicMarkup.name,u.italicMarkup.attribs);u.italicMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"makeUnderline",value:function(){var t=this.createElement(u.underlineMarkup.name,u.underlineMarkup.attribs);u.underlineMarkup.trim&&this.trimRange(),this.forceWrap(t)}},{key:"toggleUnderline",value:function(){var t=this.createElement(u.underlineMarkup.name,u.underlineMarkup.attribs);u.underlineMarkup.trim&&this.trimRange(),this.toggle(t)}},{key:"insertCharacter",value:function(t){var e=this.deleteContent(),n=e.createTextNode(t);return e.insertBefore(n),e.setVisibleSelection(),e}},{key:"surround",value:function(t,e){this.range=ve(this.host,this.range,t,e),this.setVisibleSelection()}},{key:"removeSurround",value:function(t,e){this.range=pe(this.host,this.range,t),this.range=pe(this.host,this.range,e),this.setVisibleSelection()}},{key:"removeChars",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=0;e<t.length;e++){var n=t[e];this.range=pe(this.host,this.range,n)}this.setVisibleSelection()}},{key:"toggleSurround",value:function(t,e){this.containsString(t)&&this.containsString(e)?this.removeSurround(t,e):this.surround(t,e)}},{key:"removeFormatting",value:function(t){this.range=fe(this.host,this.range,t),this.setVisibleSelection()}},{key:"deleteExactSurroundingTags",value:function(){var t,n=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=kn(t))){e&&(t=e);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}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 u,i=!0,o=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){o=!0,u=t},f:function(){try{i||null==e.return||e.return()}finally{if(o)throw u}}}}(this.getAncestorTags().reverse());try{for(n.s();!(t=n.n()).done;){var r=t.value;if(this.isExactSelection(r)){r.remove();break}}}catch(t){n.e(t)}finally{n.f()}return new e(this.host,this.range)}},{key:"deleteContainedTags",value:function(){return this.getContainedTags().forEach(function(t){return t.remove()}),new e(this.host,this.range)}},{key:"deleteContent",value:function(){return this.range.deleteContents(),new fn(this.host,this.range)}},{key:"expandTo",value:function(t){this.range=ue(this.host,this.range,t),this.setVisibleSelection()}},{key:"collapseAtBeginning",value:function(t){return this.range.collapse(!0),this.setVisibleSelection(),new fn(this.host,this.range)}},{key:"collapseAtEnd",value:function(t){return this.range.collapse(!1),this.setVisibleSelection(),new fn(this.host,this.range)}},{key:"forceWrap",value:function(t){Se(this.host)||this.range.collapsed||(t=this.adoptElement(t),this.range=ae(this.host,this.range,t),this.setVisibleSelection())}},{key:"isExactSelection",value:function(t,e){return re(this.range,t,e)}},{key:"containsString",value:function(t){return ye(this.range,t)}},{key:"deleteCharacter",value:function(t){this.range=pe(this.host,this.range,t),this.setVisibleSelection()}}],r&&xn(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(fn);function In(t){return In="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},In(t)}function Mn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Ln(r.key),r)}}function Ln(t){var e=function(t){if("object"!=In(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=In(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==In(e)?e:e+""}var Pn=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.host=e&&e.jquery?e[0]:e,this.range=null==n?void 0:n.cloneRange(),this.isAnythingSelected=void 0!==n,this.isCursor=this.isAnythingSelected&&n.collapsed,this.isSelection=this.isAnythingSelected&&!this.isCursor}return e=t,n=[{key:"getCursor",value:function(){if(this.isCursor)return new fn(this.host,this.range)}},{key:"getSelection",value:function(){if(this.isSelection)return new Rn(this.host,this.range)}},{key:"forceCursor",value:function(){return this.isSelection?this.getSelection().deleteContent():this.getCursor()}},{key:"isDifferentFrom",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new t,n=this.range,r=e.range;return n&&r?!O(n,r):!(!n&&!r)}}],n&&Mn(e.prototype,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n}();function Hn(t){return Hn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Hn(t)}function qn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Vn(r.key),r)}}function Vn(t){var e=function(t){if("object"!=Hn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Hn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Hn(e)?e:e+""}var Wn=function(){return t=function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.dispatcher=e,this.win=n||window,this.selection=void 0,this.currentSelection=void 0,this.currentRange=void 0},(e=[{key:"syncSelection",value:function(){try{this.selection=E(this.win)}catch(t){return!1}return!0}},{key:"getRangeContainer",value:function(){var t,e=this.syncSelection();if(null!==(t=this.selection)&&void 0!==t&&t.rangeCount&&e){var n=this.selection.getRangeAt(0),r=R(n.commonAncestorContainer);if(r)return new Pn(r,n)}return new Pn}},{key:"getFreshRange",value:function(){return this.getRangeContainer()}},{key:"getFreshSelection",value:function(){var t=this.getRangeContainer();return t.isCursor?t.getCursor(this.win):t.getSelection(this.win)}},{key:"getSelection",value:function(){return this.currentSelection}},{key:"forceCursor",value:function(){return this.getRangeContainer().forceCursor()}},{key:"selectionChanged",value:function(){var t=this.getRangeContainer();if(t.isDifferentFrom(this.currentRange)){var e=this.currentSelection;this.currentRange=t,e&&(e.isCursor&&!this.currentRange.isCursor?this.dispatcher.notify("cursor",e.host):e.isSelection&&!this.currentRange.isSelection&&this.dispatcher.notify("selection",e.host)),this.currentRange.isCursor?(this.currentSelection=new fn(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("cursor",this.currentSelection.host,this.currentSelection)):this.currentRange.isSelection?(this.currentSelection=new Rn(this.currentRange.host,this.currentRange.range),this.dispatcher.notify("selection",this.currentSelection.host,this.currentSelection)):this.currentSelection=void 0}}}])&&qn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Un(t){return Un="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Un(t)}function $n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,zn(r.key),r)}}function zn(t){var e=function(t){if("object"!=Un(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Un(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Un(e)?e:e+""}var Kn=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),an(this),this.selectionWatcher=e}return e=t,r=[{key:"getNodeToRemove",value:function(e,n){if(0===e.startOffset){var r=e.startContainer;if(r.nodeType===h&&(r=r.parentNode),r!==n){var u=A();if(u.setStartBefore(r.firstChild),u.setEndAfter(r.lastChild),o=e,!((i=u).compareBoundaryPoints(Range.START_TO_START,o)<=0&&i.compareBoundaryPoints(Range.END_TO_END,o)>=0)){var i,o;if(e.startContainer.nodeType===h){var a=[h,f],s=r.firstChild;do{if(-1!==a.indexOf(s.nodeType))break}while(s=s.nextSibling);if(s!==e.startContainer)return}var c=e.cloneRange();return c.setStartBefore(r),t.getNodeToRemove(c,n)||r}}}}}],(n=[{key:"dispatchKeyEvent",value:function(t,e,n){switch(t.keyCode){case this.key.left:return this.notify(e,"left",t);case this.key.right:return this.notify(e,"right",t);case this.key.up:return this.notify(e,"up",t);case this.key.down:return this.notify(e,"down",t);case this.key.tab:return t.shiftKey?this.notify(e,"shiftTab",t):this.notify(e,"tab",t);case this.key.esc:return this.notify(e,"esc",t);case this.key.backspace:return this.preventContenteditableBug(e,t),this.notify(e,"backspace",t);case this.key.delete:return this.preventContenteditableBug(e,t),this.notify(e,"delete",t);case this.key.enter:return t.shiftKey?this.notify(e,"shiftEnter",t):this.notify(e,"enter",t);case this.key.ctrl:case this.key.shift:case this.key.alt:case 224:case 17:case 91:case 93:return;default:if(t.keyCode===this.key.b&&(t.ctrlKey||t.metaKey))return this.notify(e,"bold",t);if(t.keyCode===this.key.i&&(t.ctrlKey||t.metaKey))return this.notify(e,"italic",t);if(this.preventContenteditableBug(e,t),!n)return;if(!t.ctrlKey&&!t.metaKey)return this.notify(e,"character",t)}}},{key:"preventContenteditableBug",value:function(e,n){if(on&&!n.ctrlKey&&!n.metaKey){var r=this.selectionWatcher.getFreshRange();if(r.isSelection){var u=t.getNodeToRemove(r.range,e);u&&u.remove()}}}}])&&$n(e.prototype,n),r&&$n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,n,r}();function Qn(t){return function(t){if(Array.isArray(t))return Gn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Xn(t)||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.")}()}function Xn(t,e){if(t){if("string"==typeof t)return Gn(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Gn(t,e):void 0}}function Gn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}Kn.key=Kn.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 Yn=function(t){return/^[«»"“”„]$/.test(t)},Jn=function(t){return/^[‘’‹›‚']$/.test(t)},Zn=function(t){return/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])$/.test(t)},tr=function(t){return!t||/^[\s([{/\-–—]$/.test(t)},er=[{when:function(t){return Zn(t.typed)&&t.before===t.singleQuotes[1]&&Zn(t.beforeBefore)&&t.apostrophe!==t.singleQuotes[1]},write:function(t){return t.apostrophe},writeAt:"before"},{when:function(t){return Jn(t.typed)&&(tr(t.before)||Yn(t.before))},write:function(t){return t.singleQuotes[0]},writeAt:"typed"},{when:function(t){return Jn(t.typed)&&!tr(t.before)&&(c=t.after,!Zn(c)&&!/^(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDD40-\uDD49\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDED0-\uDEE3\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59\uDFF0-\uDFF9]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDDE0-\uDDE9\uDF50-\uDF59\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD818[\uDD30-\uDD39]|\uD81A[\uDE60-\uDE69\uDEC0-\uDEC9\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDD70-\uDD79\uDE80-\uDE96\uDFF4-\uDFF6]|\uD833[\uDCF0-\uDCF9]|\uD834[\uDEC0-\uDED3\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD839[\uDCF0-\uDCF9\uDDF1-\uDDFA]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])$/.test(c))&&(r=t.text,u=t.index,i=t.singleQuotes,n=2,o=function(t){if(Array.isArray(t))return t}(e=i)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,u,i,o,a=[],s=!0,c=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;s=!1}else for(;!(s=(r=i.call(n)).done)&&(a.push(r.value),a.length!==e);s=!0);}catch(t){c=!0,u=t}finally{try{if(!s&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw u}}return a}}(e,n)||Xn(e,n)||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.")}(),a=o[0],s=o[1],Qn(r.slice(0,u)).findLast(function(t){return t===a||t===s})===a);var e,n,r,u,i,o,a,s,c},write:function(t){return t.singleQuotes[1]},writeAt:"typed"},{when:function(t){return Jn(t.typed)&&!tr(t.before)},write:function(t){return t.apostrophe},writeAt:"typed"},{when:function(t){return Yn(t.typed)&&tr(t.before)},write:function(t){return t.quotes[0]},writeAt:"typed"},{when:function(t){return Yn(t.typed)&&!tr(t.before)},write:function(t){return t.quotes[1]},writeAt:"typed"}],nr=function(t,e,n,r){var u=n.quotes,i=n.singleQuotes,o=n.apostrophe;if(![].concat(Qn(u),Qn(i),[o]).includes(r)&&(Jn(r)||Yn(r)||o&&Zn(r))){var a=function(t){var e,n="",r=[],u=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=Xn(t))){e&&(t=e);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}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 u,i=!0,o=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){o=!0,u=t},f:function(){try{i||null==e.return||e.return()}finally{if(o)throw u}}}}(new y(t));try{for(u.s();!(e=u.n()).done;){var i,o=e.value;o.nodeType!==h&&"BR"!==o.nodeName||(r.push({node:o,start:n.length}),n+=null!==(i=o.nodeValue)&&void 0!==i?i:"\n")}}catch(t){u.e(t)}finally{u.f()}return{text:n,nodes:r}}(t),s=a.text,c=a.nodes,l=function(t,e){var n=e.startContainer,r=e.startOffset;if(n.nodeType===h){var u=t.find(function(t){return t.node===n});return u?u.start+r:void 0}}(c,e);if(void 0!==l&&s[l-1]===r){var f=function(t,e,n){var r=e-1,u={quotes:n.quotes,singleQuotes:n.singleQuotes,apostrophe:n.apostrophe,text:t,index:r,typed:t[r],before:t[r-1],beforeBefore:t[r-2],after:t[r+1]},i=er.find(function(t){return t.when(u)}),o=null==i?void 0:i.write(u);if(o)return{index:"before"===i.writeAt?r-1:r,char:o}}(s,l,n);f&&function(t,e,n){var r=t.findLast(function(t){return t.start<=e}),u=r.node,i=r.start,o=e-i;u.insertData(o,n),u.deleteData(o+n.length,1)}(c,f.index,f.char)}}},rr=function(t){return Array.isArray(t)&&2===t.length};function ur(t){return ur="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ur(t)}function ir(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return or(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?or(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,u=function(){};return{s:u,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:u}}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 i,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function or(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ar(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,sr(r.key),r)}}function sr(t){var e=function(t){if("object"!=ur(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=ur(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ur(e)?e:e+""}var cr=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=e.win;an(this,e),this.document=n.document,this.config=e.config,this.editable=e,this.editableSelector=e.editableSelector,this.selectionWatcher=new Wn(this,n),this.keyboard=new Kn(this.selectionWatcher),this.activeListeners=[],this.setup(),this.getEditableBlockByEvent=function(t){return C(t.target,e.editableSelector)}},e=[{key:"setupDocumentListener",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r={event:t,listener:e.bind(this),capture:n};return this.activeListeners.push(r),this.document.addEventListener(t,r.listener,n),this}},{key:"setup",value:function(){this.setupKeyboardEvents(),this.setupEventListeners()}},{key:"unload",value:function(){this.off();var t,e=ir(this.activeListeners);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(t){e.e(t)}finally{e.f()}this.activeListeners.length=0}},{key:"suspend",value:function(){if(!this.suspended){this.suspended=!0;var t,e=ir(this.activeListeners);try{for(e.s();!(t=e.n()).done;){var n=t.value;this.document.removeEventListener(n.event,n.listener,n.capture)}}catch(t){e.e(t)}finally{e.f()}this.activeListeners.length=0}}},{key:"continue",value:function(){this.suspended&&(this.suspended=!1,this.setupEventListeners())}},{key:"setupEventListeners",value:function(){this.setupElementListeners(),this.setupKeydownListener(),un?this.setupSelectionChangeListeners():this.setupSelectionChangeFallbackListeners()}},{key:"setupElementListeners",value:function(){this.setupDocumentListener("focus",function(t){var e=this.getEditableBlockByEvent(t);e&&(t.target.getAttribute(u.pastingAttribute)||(this.selectionWatcher.syncSelection(),this.notify("focus",e)))},!0).setupDocumentListener("blur",function(t){var e=this.getEditableBlockByEvent(t);e&&(e.getAttribute(u.pastingAttribute)||this.notify("blur",e))},!0).setupDocumentListener("copy",function(t){var e=this.getEditableBlockByEvent(t);if(e){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&this.notify("clipboard",e,"copy",n)}}).setupDocumentListener("cut",function(t){var e=this.getEditableBlockByEvent(t);if(e){var n=this.selectionWatcher.getFreshSelection();n&&n.isSelection&&this.notify("clipboard",e,"cut",n)}}).setupDocumentListener("paste",function(t){var e=this.getEditableBlockByEvent(t);if(e){t.preventDefault();var n,r=this.selectionWatcher.getFreshSelection(),u=t.clipboardData.getData("text/html")||t.clipboardData.getData("text/plain"),i=Ze(e,r,u),o=i.blocks,a=i.cursor;o.length?(n=t.target.innerText,/\S+\s{1}$/.test(n)&&a.retainVisibleSelection(function(){e.innerHTML=function(t,e){if(!t)return"";var n=(t="".concat(t)).lastIndexOf(e);return-1===n?t:"".concat(t.slice(0,n)).concat(" ").concat(t.slice(n+6))}(e.innerHTML,"&nbsp;")}),this.notify("paste",e,o,a),this.notify("change",e)):a.setVisibleSelection()}}).setupDocumentListener("input",function(t){var e=this.getEditableBlockByEvent(t);if(e){if(function(t,e){var n=t.smartQuotes,r=t.quotes,u=t.singleQuotes;return!!n&&rr(r)&&rr(u)&&e.isContentEditable}(u,t.target)){var n=this.selectionWatcher.getFreshSelection();setTimeout(function(){nr(e,n.range,u,t.data)},300)}this.notify("change",e)}}).setupDocumentListener("formatEditable",function(t){var e=this.getEditableBlockByEvent(t);e&&this.notify("change",e)})}},{key:"dispatchSwitchEvent",value:function(t,e,n){if(!(t.altKey||t.ctrlKey||t.metaKey||t.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()&&(t.preventDefault(),t.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",e,n,r)),"down"===n&&r.isAtLastLine()&&(t.preventDefault(),t.stopPropagation(),this.switchContext.events=["switch","blur","focus","cursor"],this.notify("switch",e,n,r)))}}},{key:"setupKeydownListener",value:function(){this.setupDocumentListener("keydown",function(t){var e=this.getEditableBlockByEvent(t);e&&this.keyboard.dispatchKeyEvent(t,e,!1)},!0)}},{key:"setupKeyboardEvents",value:function(){var t=this;this.keyboard.on("up",function(e){t.dispatchSwitchEvent(e,this,"up")}).on("down",function(e){t.dispatchSwitchEvent(e,this,"down")}).on("backspace",function(e){var n=t.selectionWatcher.getFreshRange();if(n.isCursor){var r=n.getCursor();r.isAtBeginning()&&(e.preventDefault(),e.stopPropagation(),t.notify("merge",this,"before",r))}}).on("delete",function(e){var n=t.selectionWatcher.getFreshRange();if(n.isCursor){var r=n.getCursor();r.isAtTextEnd()&&(e.preventDefault(),e.stopPropagation(),t.notify("merge",this,"after",r))}}).on("enter",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshRange().forceCursor();n.isAtTextEnd()?t.notify("insert",this,"after",n):n.isAtBeginning()?t.notify("insert",this,"before",n):t.notify("split",this,n.before(),n.after(),n)}).on("shiftEnter",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.forceCursor();t.notify("newline",this,n)}).on("bold",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshSelection();n.isSelection&&t.notify("toggleBold",n)}).on("italic",function(e){e.preventDefault(),e.stopPropagation();var n=t.selectionWatcher.getFreshSelection();n.isSelection&&t.notify("toggleEmphasis",n)}).on("character",function(e){t.notify("change",this)})}},{key:"setupSelectionChangeListeners",value:function(){var t=this,e=!1,n=!1,r=this.selectionWatcher;this.setupDocumentListener("selectionchange",function(u){var i=t.selectionWatcher.getFreshSelection();i&&i.isSelection&&i.isAtBeginning()&&i.isAtEnd()?t.notify("selectToBoundary",i.host,u,"both"):i&&i.isSelection&&i.isAtBeginning()?t.notify("selectToBoundary",i.host,u,"start"):i&&i.isSelection&&i.isAtEnd()&&t.notify("selectToBoundary",i.host,u,"end"),n?e=!0:r.selectionChanged()}),this.setupDocumentListener("mousedown",function(t){this.getEditableBlockByEvent(t)&&(!1===this.config.mouseMoveSelectionChanges&&(n=!0,setTimeout(function(){return r.selectionChanged()},0)),this.document.addEventListener("mouseup",function(){n=!1,e&&(e=!1,r.selectionChanged())},{capture:!0,once:!0}))})}},{key:"setupSelectionChangeFallbackListeners",value:function(){var t=this;this.setupDocumentListener("mouseup",function(){setTimeout(function(){return t.selectionWatcher.selectionChanged()},0)}),this.setupDocumentListener("keyup",function(e){t.getEditableBlockByEvent(e)&&t.selectionWatcher.selectionChanged()})}}],e&&ar(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();const lr=function(t,e){return t===e||t!=t&&e!=e},fr=function(t,e){for(var n=t.length;n--;)if(lr(t[n][0],e))return n;return-1};var hr=Array.prototype.splice;function dr(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}dr.prototype.clear=function(){this.__data__=[],this.size=0},dr.prototype.delete=function(t){var e=this.__data__,n=fr(e,t);return!(n<0||(n==e.length-1?e.pop():hr.call(e,n,1),--this.size,0))},dr.prototype.get=function(t){var e=this.__data__,n=fr(e,t);return n<0?void 0:e[n][1]},dr.prototype.has=function(t){return fr(this.__data__,t)>-1},dr.prototype.set=function(t,e){var n=this.__data__,r=fr(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};const Dr=dr,vr="object"==typeof t.g&&t.g&&t.g.Object===Object&&t.g;var pr="object"==typeof self&&self&&self.Object===Object&&self;const yr=vr||pr||Function("return this")(),gr=yr.Symbol;var mr=Object.prototype,br=mr.hasOwnProperty,Cr=mr.toString,Ar=gr?gr.toStringTag:void 0;var Er=Object.prototype.toString;var Fr=gr?gr.toStringTag:void 0;const wr=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Fr&&Fr in Object(t)?function(t){var e=br.call(t,Ar),n=t[Ar];try{t[Ar]=void 0;var r=!0}catch(t){}var u=Cr.call(t);return r&&(e?t[Ar]=n:delete t[Ar]),u}(t):function(t){return Er.call(t)}(t)},Sr=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Br=function(t){if(!Sr(t))return!1;var e=wr(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},kr=yr["__core-js_shared__"];var Tr,xr=(Tr=/[^.]+$/.exec(kr&&kr.keys&&kr.keys.IE_PROTO||""))?"Symbol(src)_1."+Tr:"";var Or=Function.prototype.toString;var Nr=/^\[object .+?Constructor\]$/,jr=Function.prototype,_r=Object.prototype,Rr=jr.toString,Ir=_r.hasOwnProperty,Mr=RegExp("^"+Rr.call(Ir).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const Lr=function(t){return!(!Sr(t)||(e=t,xr&&xr in e))&&(Br(t)?Mr:Nr).test(function(t){if(null!=t){try{return Or.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e},Pr=function(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Lr(n)?n:void 0},Hr=Pr(yr,"Map"),qr=Pr(Object,"create");var Vr=Object.prototype.hasOwnProperty;var Wr=Object.prototype.hasOwnProperty;function Ur(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Ur.prototype.clear=function(){this.__data__=qr?qr(null):{},this.size=0},Ur.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Ur.prototype.get=function(t){var e=this.__data__;if(qr){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return Vr.call(e,t)?e[t]:void 0},Ur.prototype.has=function(t){var e=this.__data__;return qr?void 0!==e[t]:Wr.call(e,t)},Ur.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=qr&&void 0===e?"__lodash_hash_undefined__":e,this};const $r=Ur,zr=function(t,e){var n,r,u=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?u["string"==typeof e?"string":"hash"]:u.map};function Kr(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Kr.prototype.clear=function(){this.size=0,this.__data__={hash:new $r,map:new(Hr||Dr),string:new $r}},Kr.prototype.delete=function(t){var e=zr(this,t).delete(t);return this.size-=e?1:0,e},Kr.prototype.get=function(t){return zr(this,t).get(t)},Kr.prototype.has=function(t){return zr(this,t).has(t)},Kr.prototype.set=function(t,e){var n=zr(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};const Qr=Kr;function Xr(t){var e=this.__data__=new Dr(t);this.size=e.size}Xr.prototype.clear=function(){this.__data__=new Dr,this.size=0},Xr.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Xr.prototype.get=function(t){return this.__data__.get(t)},Xr.prototype.has=function(t){return this.__data__.has(t)},Xr.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Dr){var r=n.__data__;if(!Hr||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new Qr(r)}return n.set(t,e),this.size=n.size,this};const Gr=Xr,Yr=function(){try{var t=Pr(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Jr=function(t,e,n){"__proto__"==e&&Yr?Yr(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n},Zr=function(t,e,n){(void 0!==n&&!lr(t[e],n)||void 0===n&&!(e in t))&&Jr(t,e,n)},tu=function(t,e,n){for(var r=-1,u=Object(t),i=n(t),o=i.length;o--;){var a=i[++r];if(!1===e(u[a],a,u))break}return t};var eu="object"==typeof exports&&exports&&!exports.nodeType&&exports,nu=eu&&"object"==typeof module&&module&&!module.nodeType&&module,ru=nu&&nu.exports===eu?yr.Buffer:void 0,uu=ru?ru.allocUnsafe:void 0;const iu=yr.Uint8Array,ou=function(t,e){var n,r,u=e?(n=t.buffer,r=new n.constructor(n.byteLength),new iu(r).set(new iu(n)),r):t.buffer;return new t.constructor(u,t.byteOffset,t.length)};var au=Object.create;const su=function(){function t(){}return function(e){if(!Sr(e))return{};if(au)return au(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}(),cu=(lu=Object.getPrototypeOf,fu=Object,function(t){return lu(fu(t))});var lu,fu,hu=Object.prototype;const du=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||hu)},Du=function(t){return null!=t&&"object"==typeof t},vu=function(t){return Du(t)&&"[object Arguments]"==wr(t)};var pu=Object.prototype,yu=pu.hasOwnProperty,gu=pu.propertyIsEnumerable;const mu=vu(function(){return arguments}())?vu:function(t){return Du(t)&&yu.call(t,"callee")&&!gu.call(t,"callee")},bu=Array.isArray,Cu=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},Au=function(t){return null!=t&&Cu(t.length)&&!Br(t)};var Eu="object"==typeof exports&&exports&&!exports.nodeType&&exports,Fu=Eu&&"object"==typeof module&&module&&!module.nodeType&&module,wu=Fu&&Fu.exports===Eu?yr.Buffer:void 0;const Su=(wu?wu.isBuffer:void 0)||function(){return!1};var Bu=Function.prototype,ku=Object.prototype,Tu=Bu.toString,xu=ku.hasOwnProperty,Ou=Tu.call(Object);var Nu={};Nu["[object Float32Array]"]=Nu["[object Float64Array]"]=Nu["[object Int8Array]"]=Nu["[object Int16Array]"]=Nu["[object Int32Array]"]=Nu["[object Uint8Array]"]=Nu["[object Uint8ClampedArray]"]=Nu["[object Uint16Array]"]=Nu["[object Uint32Array]"]=!0,Nu["[object Arguments]"]=Nu["[object Array]"]=Nu["[object ArrayBuffer]"]=Nu["[object Boolean]"]=Nu["[object DataView]"]=Nu["[object Date]"]=Nu["[object Error]"]=Nu["[object Function]"]=Nu["[object Map]"]=Nu["[object Number]"]=Nu["[object Object]"]=Nu["[object RegExp]"]=Nu["[object Set]"]=Nu["[object String]"]=Nu["[object WeakMap]"]=!1;var ju="object"==typeof exports&&exports&&!exports.nodeType&&exports,_u=ju&&"object"==typeof module&&module&&!module.nodeType&&module,Ru=_u&&_u.exports===ju&&vr.process,Iu=function(){try{return _u&&_u.require&&_u.require("util").types||Ru&&Ru.binding&&Ru.binding("util")}catch(t){}}(),Mu=Iu&&Iu.isTypedArray;const Lu=Mu?function(t){return function(e){return t(e)}}(Mu):function(t){return Du(t)&&Cu(t.length)&&!!Nu[wr(t)]},Pu=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};var Hu=Object.prototype.hasOwnProperty;const qu=function(t,e,n){var r=t[e];Hu.call(t,e)&&lr(r,n)&&(void 0!==n||e in t)||Jr(t,e,n)};var Vu=/^(?:0|[1-9]\d*)$/;const Wu=function(t,e){var n=typeof t;return!!(e=e??9007199254740991)&&("number"==n||"symbol"!=n&&Vu.test(t))&&t>-1&&t%1==0&&t<e};var Uu=Object.prototype.hasOwnProperty;const $u=function(t,e){var n=bu(t),r=!n&&mu(t),u=!n&&!r&&Su(t),i=!n&&!r&&!u&&Lu(t),o=n||r||u||i,a=o?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],s=a.length;for(var c in t)!e&&!Uu.call(t,c)||o&&("length"==c||u&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Wu(c,s))||a.push(c);return a};var zu=Object.prototype.hasOwnProperty;const Ku=function(t){if(!Sr(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=du(t),n=[];for(var r in t)("constructor"!=r||!e&&zu.call(t,r))&&n.push(r);return n},Qu=function(t){return Au(t)?$u(t,!0):Ku(t)},Xu=function(t){return function(t,e,n,r){var u=!n;n||(n={});for(var i=-1,o=e.length;++i<o;){var a=e[i],s=r?r(n[a],t[a],a,n,t):void 0;void 0===s&&(s=t[a]),u?Jr(n,a,s):qu(n,a,s)}return n}(t,Qu(t))},Gu=function(t,e,n,r,u,i,o){var a,s=Pu(t,n),c=Pu(e,n),l=o.get(c);if(l)Zr(t,n,l);else{var f=i?i(s,c,n+"",t,e,o):void 0,h=void 0===f;if(h){var d=bu(c),D=!d&&Su(c),v=!d&&!D&&Lu(c);f=c,d||D||v?bu(s)?f=s:Du(a=s)&&Au(a)?f=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(s):D?(h=!1,f=function(t,e){if(e)return t.slice();var n=t.length,r=uu?uu(n):new t.constructor(n);return t.copy(r),r}(c,!0)):v?(h=!1,f=ou(c,!0)):f=[]:function(t){if(!Du(t)||"[object Object]"!=wr(t))return!1;var e=cu(t);if(null===e)return!0;var n=xu.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Tu.call(n)==Ou}(c)||mu(c)?(f=s,mu(s)?f=Xu(s):Sr(s)&&!Br(s)||(f=function(t){return"function"!=typeof t.constructor||du(t)?{}:su(cu(t))}(c))):h=!1}h&&(o.set(c,f),u(f,c,r,i,o),o.delete(c)),Zr(t,n,f)}},Yu=function t(e,n,r,u,i){e!==n&&tu(n,function(o,a){if(i||(i=new Gr),Sr(o))Gu(e,n,a,r,t,u,i);else{var s=u?u(Pu(e,a),o,a+"",e,n,i):void 0;void 0===s&&(s=o),Zr(e,a,s)}},Qu)},Ju=function(t){return t};var Zu=Math.max;const ti=Yr?function(t,e){return Yr(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:Ju;var ei=Date.now;const ni=function(t){var e=0,n=0;return function(){var r=ei(),u=16-(r-n);if(n=r,u>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(ti),ri=function(t,e){return ni(function(t,e,n){return e=Zu(void 0===e?t.length-1:e,0),function(){for(var r=arguments,u=-1,i=Zu(r.length-e,0),o=Array(i);++u<i;)o[u]=r[e+u];u=-1;for(var a=Array(e+1);++u<e;)a[u]=r[u];return a[e]=n(o),function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}(t,this,a)}}(t,e,Ju),t+"")},ui=(ii=function(t,e,n){Yu(t,e,n)},ri(function(t,e){var n=-1,r=e.length,u=r>1?e[r-1]:void 0,i=r>2?e[2]:void 0;for(u=ii.length>3&&"function"==typeof u?(r--,u):void 0,i&&function(t,e,n){if(!Sr(n))return!1;var r=typeof e;return!!("number"==r?Au(n)&&Wu(e,n.length):"string"==r&&e in n)&&lr(n[e],t)}(e[0],e[1],i)&&(u=r<3?void 0:u,r=1),t=Object(t);++n<r;){var o=e[n];o&&ii(t,o,n)}return t}));var ii;function oi(t){return oi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},oi(t)}function ai(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,si(r.key),r)}}function si(t){var e=function(t){if("object"!=oi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=oi(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==oi(e)?e:e+""}var ci=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.spellcheckService=e},(e=[{key:"check",value:function(t,e){if(!t)return e(null);var n=Lt(t);this.spellcheckService(n,function(t){return t&&t.length>0?e(null,t):e(null)})}}])&&ai(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function li(t){return li="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},li(t)}function fi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function hi(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,di(r.key),r)}}function di(t){var e=function(t){if("object"!=li(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=li(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==li(e)?e:e+""}var Di={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"},vi=new RegExp("[".concat("\\u2000-\\u200A\\u202F\\u205F\\u3000","]"),"g"),pi=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.marker=e},(e=[{key:"findMatches",value:function(t){var e=this;if(t)return function(t){return function(t){if(Array.isArray(t))return fi(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return fi(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fi(t,e):void 0}}(t)||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.")}()}(t.matchAll(vi)).map(function(t){return e.prepareMatch(t)})}},{key:"prepareMatch",value:function(t){var e,n=t.index,r=(e=t[0].charCodeAt(0),"".concat(e.toString(16).toUpperCase())),u=Di[r];return{startIndex:n,endIndex:n+t.length,match:t[0],title:"".concat(u," (\\u").concat(r,")"),marker:this.marker}}}])&&hi(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function yi(t){return yi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yi(t)}function gi(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,mi(r.key),r)}}function mi(t){var e=function(t){if("object"!=yi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=yi(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yi(e)?e:e+""}var bi=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.matches=[]},e=[{key:"addMatches",value:function(t){null!=t&&t.length&&(this.matches=function(t,e){for(var n,r=t.length,u=e.length,i=-1,o=[],a={a1:t,i1:0,a2:e,i2:0};a.i1<r||a.i2<u;)(n=Ci(a)).startIndex>=i&&o.push(n),i=n.endIndex;return o}(this.matches,t))}}],e&&gi(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function Ci(t){var e=t.i1,n=t.i2,r=t.a1[e],u=t.a2[n];return r&&u&&r.startIndex<u.startIndex?(t.i1=e+1,r):r&&u?(t.i2=n+1,u):r?(t.i1=e+1,r):u?(t.i2=n+1,u):void 0}function Ai(t){return Ai="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ai(t)}function Ei(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Fi(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Fi(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,u=function(){};return{s:u,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:u}}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 i,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function Fi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function wi(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Si(r.key),r)}}function Si(t){var e=function(t){if("object"!=Ai(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ai(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ai(e)?e:e+""}var Bi=function(){return t=function t(e,n,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.editable=e,this.win=e.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 u=this.config.spellcheck.spellcheckService,i=this.config.spellcheck.marker,o=this.config.whitespace.marker,a=wn.createMarkerNode(o,"whitespace",this.win);this.spellcheckMarkerNode=wn.createMarkerNode(i,"spellcheck",this.win),this.spellcheckService=new ci(u),this.whitespace=new pi(a),this.setupListeners()},e=[{key:"setupListeners",value:function(){var t=this;this.config.checkOnFocus&&(this.editable.on("focus",function(){return t.onFocus.apply(t,arguments)}),this.editable.on("blur",function(){return t.onBlur.apply(t,arguments)})),(this.config.checkOnChange||this.config.removeOnCorrection)&&this.editable.on("change",function(){return t.onChange.apply(t,arguments)}),this.config.checkOnInit&&this.editable.on("init",function(){return t.onInit.apply(t,arguments)})}},{key:"onInit",value:function(t){this.highlight(t)}},{key:"onFocus",value:function(t){this.focusedEditableHost!==t&&(this.focusedEditableHost=t,this.editableHasChanged(t))}},{key:"onBlur",value:function(t){this.focusedEditableHost===t&&(this.focusedEditableHost=void 0)}},{key:"onChange",value:function(t){this.config.checkOnChange&&this.editableHasChanged(t,this.config.throttle),this.config.removeOnCorrection&&this.removeHighlightsAtCursor(t)}},{key:"editableHasChanged",value:function(t,e){var n=this;this.timeout.id&&this.timeout.editableHost===t&&clearTimeout(this.timeout.id);var r=setTimeout(function(){n.highlight(t),n.timeout={}},e||0);this.timeout={id:r,editableHost:t}}},{key:"highlight",value:function(t){var e=this,n=Dn.extractText(t);this.spellcheckService.check(n,function(n,r){if(!n&&t.isConnected){var u=Dn.extractText(t),i=new bi,o=function(t,e,n){return yn(t,e,"word",n)}(u,r,e.spellcheckMarkerNode);i.addMatches(o),o=e.whitespace.findMatches(u),i.addMatches(o),e.safeHighlightMatches(t,i.matches)}})}},{key:"safeHighlightMatches",value:function(t,e){var n=this,r=this.editable.getSelection(t);r?r.retainVisibleSelection(function(){n.highlightMatches(t,e)}):this.highlightMatches(t,e),this.editable.dispatcher&&this.editable.dispatcher.notify("spellcheckUpdated",t)}},{key:"highlightMatches",value:function(t,e){this.removeHighlights(t),e&&e.length>0&&Dn.highlightMatches(t,e)}},{key:"removeHighlights",value:function(t){t=m(t,this.win.document);var e,n=Ei(g('[data-highlight="spellcheck"], [data-highlight="whitespace"]',t));try{for(n.s();!(e=n.n()).done;)ce(e.value)}catch(t){n.e(t)}finally{n.f()}}},{key:"removeHighlightsAtCursor",value:function(t){t=m(t,this.win.document);var e=this.editable.getSelection(t);if(e&&e.isCursor){var n,r=e.range.startContainer;r.nodeType===h&&(r=r.parentNode);do{if(r===t)return;var u=r.getAttribute("data-highlight");if("spellcheck"===u||"whitespace"===u){n=r.getAttribute("data-word-id");break}}while(r=r.parentNode);n&&e.retainVisibleSelection(function(){var e,r=Ei(g('[data-word-id="'.concat(n,'"]'),t));try{for(r.s();!(e=r.n()).done;)ce(e.value)}catch(t){r.e(t)}finally{r.f()}})}}}],e&&wi(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function ki(){if(!1!==u.log&&t.g.console){var e=1===arguments.length?arguments[0]:Array.from(arguments);return 1!==arguments.length&&"trace"===e[e.length-1]&&(e.pop(),console.trace&&console.trace()),console.log(e)}}function Ti(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function xi(t){return function(t){if(Array.isArray(t))return Ti(t)}(e=new y(t,"getNextTextNode"))||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(t,e){if(t){if("string"==typeof t)return Ti(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ti(t,e):void 0}}(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 e}function Oi(t){for(var e,n=t.textNodes,r=t.absOffset,u=0,i=0,o=0;o<n.length;o++){var a=n[o];if(r<=u+a.textContent.length){e=a,i=r-u;break}u+=a.textContent.length}return{node:e,relativeOffset:i}}function Ni(t){t.rightLimit=t.currentOffset,t.currentOffset=Math.floor((t.currentOffset+t.leftLimit)/2)}function ji(t){t.leftLimit=t.currentOffset,t.currentOffset=Math.ceil((t.currentOffset+t.rightLimit)/2)}function _i(t){var e=Oi({textNodes:t.textNodes,absOffset:t.offset}),n=e.node,r=e.relativeOffset,u=n.ownerDocument.createRange();return u.setStart(n,r),u.collapse(!0),u}function Ri(t){return Ri="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ri(t)}function Ii(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Mi(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mi(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,u=function(){};return{s:u,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:u}}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 i,o=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==n.return||n.return()}finally{if(a)throw i}}}}function Mi(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Li(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Pi(r.key),r)}}function Pi(t){var e=function(t){if("object"!=Ri(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ri(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ri(e)?e:e+""}var Hi=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n,r={window,defaultBehavior:!0,mouseMoveSelectionChanges:!1,browserSpellcheck:!0};this.config=Object.assign(r,e),this.win=this.config.window,this.editableSelector=".".concat(u.editableClass),this.dispatcher=new cr(this),!0===this.config.defaultBehavior&&this.dispatcher.on((n=function(t){var e=t.win.document;return{focus:function(t){M(t)&&t.appendChild(e.createTextNode("\ufeff"))},blur:function(t){e.activeElement!==t&&Pt(t)},selection:function(t,e){ki(e?"Default selection behavior":"Default selection empty behavior")},cursor:function(t,e){ki(e?"Default cursor behavior":"Default cursor empty behavior")},newline:function(t,n){if(n.isAtTextEnd()){var r,u=e.createElement("br");n.insertBefore(u),(null===(r=u.nextSibling)||void 0===r?void 0:r.nodeType)===h&&"\ufeff"===u.nextSibling.textContent[0]||n.insertAfter(e.createTextNode("\ufeff"))}else n.insertBefore(e.createElement("br"));n.setVisibleSelection()},insert:function(t,e,n){var r=t.parentNode,u=t.cloneNode(!1);switch(u.id&&u.removeAttribute("id"),e){case"before":r.insertBefore(u,t),t.focus();break;case"after":r.insertBefore(u,t.nextSibling),u.focus()}},split:function(t,e,n,r){var u=t.cloneNode(!1);for(u.appendChild(e),t.parentNode.insertBefore(u,t);t.firstChild;)t.removeChild(t.firstChild);t.appendChild(n),It(u),It(t),t.focus()},merge:function(e,n,r){var u,i;switch(n){case"before":u=Ee(e),i=e;break;case"after":u=e,i=Ae(e)}u&&i&&(r=u.childNodes.length>0?t.appendTo(u,i.innerHTML):t.prependTo(u,i.innerHTML),i.remove(),r.save(),It(u),r.restore(),r.setVisibleSelection())},empty:function(t){ki("Default empty behavior")},switch:function(t,e,n){switch(e){case"before":var r=Ee(t);r&&(n.moveAtTextEnd(r),n.setVisibleSelection());break;case"after":var u=Ae(t);u&&(n.moveAtBeginning(u),n.setVisibleSelection())}},move:function(t,e,n){ki("Default move behavior")},paste:function(e,n,r){if(0!==n.length){if(r.insertBefore(n.shift()),0===n.length)return r.setVisibleSelection();var u=e.parentNode,i=e;n.forEach(function(t){var n=e.cloneNode(!1);n.id&&n.removeAttribute("id");var r=Vt(t);n.appendChild(r),u.insertBefore(n,i.nextSibling),i=n}),t.createCursorAtEnd(i).setVisibleSelection()}},clipboard:function(t,e,n){ki("Default clipboard behavior")},toggleBold:function(t){t.toggleBold()},toggleEmphasis:function(t){t.toggleEmphasis()}}}(this),{focus:function(t){n.focus(t)},blur:function(t){n.blur(t)},flow:function(t,e){n.flow(t,e)},selection:function(t,e){n.selection(t,e)},cursor:function(t,e){n.cursor(t,e)},newline:function(t,e){n.newline(t,e)},split:function(t,e,r,u){n.split(t,e,r,u)},insert:function(t,e,r){n.insert(t,e,r)},merge:function(t,e,r){n.merge(t,e,r)},empty:function(t){n.empty(t)},switch:function(t,e,r){n.switch(t,e,r)},move:function(t,e,r){n.move(t,e,r)},clipboard:function(t,e,r){n.clipboard(t,e,r)},paste:function(t,e,r){n.paste(t,e,r)},toggleBold:function(t){n.toggleBold(t)},toggleEmphasis:function(t){n.toggleEmphasis(t)}}))},e=[{key:"add",value:function(t,e){return this.enable(t,e),this}},{key:"remove",value:function(t){var e=g(t,this.win.document);this.disable(e);var n,r=Ii(e);try{for(r.s();!(n=r.n()).done;)n.value.classList.remove(u.editableDisabledClass)}catch(t){r.e(t)}finally{r.f()}return this}},{key:"disable",value:function(t){var e,n=Ii(g(t||".".concat(u.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)we(e.value)}catch(t){n.e(t)}finally{n.f()}return this}},{key:"enable",value:function(t,e){var n,r=null!=e?e:{},i=r.normalize,o=void 0===i?"boolean"==typeof e&&e:i,a=r.plainText,s=void 0!==a&&a,c=this.config.browserSpellcheck,l=Ii(g(t||".".concat(u.editableDisabledClass),this.win.document));try{for(l.s();!(n=l.n()).done;){var f=n.value;Fe(f,{normalize:o,plainText:s,shouldSpellcheck:c}),this.dispatcher.notify("init",f)}}catch(t){l.e(t)}finally{l.f()}return this}},{key:"suspend",value:function(t){var e,n=Ii(g(t||".".concat(u.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)e.value.removeAttribute("contenteditable")}catch(t){n.e(t)}finally{n.f()}return this.dispatcher.suspend(),this}},{key:"continue",value:function(t){var e,n=Ii(g(t||".".concat(u.editableClass),this.win.document));try{for(n.s();!(e=n.n()).done;)e.value.setAttribute("contenteditable",!0)}catch(t){n.e(t)}finally{n.f()}return this.dispatcher.continue(),this}},{key:"createCursor",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"beginning",n=fn.findHost(t,this.editableSelector);if(n){var r=A();return"beginning"===e||"end"===e?(r.selectNodeContents(t),r.collapse("beginning"===e)):t!==n?"before"===e?(r.setStartBefore(t),r.setEndBefore(t)):"after"===e&&(r.setStartAfter(t),r.setEndAfter(t)):i("EditableJS: cannot create cursor outside of an editable block."),new fn(n,r)}}},{key:"createCursorAtCharacterOffset",value:function(t){var e=t.element,n=t.offset,r=Oi({textNodes:xi(e),absOffset:n}),u=r.node,i=r.relativeOffset,o=A();o.setStart(u,i),o.collapse(!0);var a=fn.findHost(e,this.editableSelector),s=new fn(a,o);return s.setVisibleSelection(),s}},{key:"createCursorAtBeginning",value:function(t){return this.createCursor(t,"beginning")}},{key:"createCursorAtEnd",value:function(t){return this.createCursor(t,"end")}},{key:"createCursorBefore",value:function(t){return this.createCursor(t,"before")}},{key:"createCursorAfter",value:function(t){return this.createCursor(t,"after")}},{key:"getContent",value:function(t){return Ht(t)}},{key:"appendTo",value:function(t,e){var n=Wt(t,this.win.document),r=this.createCursor(n,"end");return r.insertAfter("string"==typeof e?Vt(e):e),r}},{key:"prependTo",value:function(t,e){var n=Wt(t,this.win.document),r=this.createCursor(n,"beginning");return r.insertBefore("string"==typeof e?Vt(e):e),r}},{key:"getSelection",value:function(t){var e=this.dispatcher.selectionWatcher.getFreshSelection();if(!t||!e)return e;var n=e.range;return null!=t&&t.isConnected&&function(t,e){var n=document.createRange();n.selectNodeContents(t);var r=e.compareBoundaryPoints(Range.START_TO_START,n),u=e.compareBoundaryPoints(Range.END_TO_END,n);return r>=0&&u<=0}(t,n)?e:void 0}},{key:"setupHighlighting",value:function(t){return this.highlighting=new Bi(this,t),this}},{key:"setupSpellcheck",value:function(t){var e,n=this;t.markerNode&&(e=t.markerNode.outerHTML),this.setupHighlighting({throttle:t.throttle,spellcheck:{marker:e,spellcheckService:t.spellcheckService}}),this.spellcheck={checkSpelling:function(t){n.highlighting.highlight(t)}}}},{key:"highlight",value:function(t){var e=t.editableHost,n=t.text,r=t.highlightId,u=t.textRange,o=t.raiseEvents,a=t.type,s=void 0===a?"comment":a;return u?"number"!=typeof u.start||"number"!=typeof u.end?(i("Error in Editable.highlight: You passed a textRange object with invalid keys. Expected shape: { start: Number, end: Number }"),-1):u.start===u.end?(i("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):wn.highlightRange(e,n,r,u.start,u.end,o?this.dispatcher:void 0,s):wn.highlightText(e,n,r,s,o?this.dispatcher:void 0)}},{key:"getHighlightPositions",value:function(t){var e=t.editableHost,n=t.type;return wn.extractHighlightedRanges(e,n)}},{key:"removeHighlight",value:function(t){var e=t.editableHost,n=t.highlightId,r=t.raiseEvents;wn.removeHighlight(e,n,r?this.dispatcher:void 0)}},{key:"decorateHighlight",value:function(t){var e=t.editableHost,n=t.highlightId,r=t.addCssClass,u=t.removeCssClass;wn.updateHighlight(e,n,r,u)}},{key:"getCssHighlightText",value:function(t){return Et(t.editableHost).text}},{key:"setCssHighlight",value:function(t){var e=t.name,n=t.ranges;!function(t){var e,n=t.name,r=t.ranges,u=void 0===r?[]:r,i=t.win,o=void 0===i?window:i,a=new Map,s=ft(u);try{for(s.s();!(e=s.n()).done;){var c=e.value,l=c.editableHost,f=c.start,h=c.end,d=a.get(l);d?d.push({start:f,end:h}):a.set(l,[{start:f,end:h}])}}catch(t){s.e(t)}finally{s.f()}if(!a.size)return Ct({name:n,win:o});var D=Dt.get(o);D||Dt.set(o,D=new Map),D.set(n,a),At({name:n,hosts:a,win:o})}({name:e,ranges:void 0===n?[]:n,win:this.win})}},{key:"deleteCssHighlight",value:function(t){Ct({name:t.name,win:this.win})}},{key:"replaceCssHighlight",value:function(t){var e=t.editableHost,n=t.start,r=t.end,u=t.text,i=bt({editableHost:e,start:n,end:r,win:this.win});return!!i&&(new Rn(e,i).insertCharacter(u).triggerChange(),!0)}},{key:"getCssHighlightRects",value:function(t){return function(t){var e=t.win,n=void 0===e?window:e,r=bt({editableHost:t.editableHost,start:t.start,end:t.end,win:n});if(r){var u=r.getBoundingClientRect(),i=Array.from(r.getClientRects()),o=at(n),a=o.x,s=o.y;return{bounding:St(u,a,s),rects:i.map(function(t){return St(t,a,s)})}}}({editableHost:t.editableHost,start:t.start,end:t.end,win:this.win})}},{key:"getCssHighlightCursorOffset",value:function(t){var e=t.editableHost,n=this.getSelection(e);if(null!=n&&n.isCursor){var r=n.range;return function(t){for(var e,n=t.editableHost,r=t.container,u=t.containerOffset,i=r.nodeType===f?r.childNodes[u]:void 0,o=Et(n),a=o.text,s=o.leading,c=function(t){return Math.min(Math.max(t-s,0),a.length)},l=new y(n),d=0;e=l.getNext();){if(e===i)return c(d);if(e.nodeType!==f||"BR"!==e.nodeName){if(e.nodeType===h&&""!==e.data){if(e===r)return c(d+gt(e.data.slice(0,u)).length);d+=gt(e.data).length}}else d+=1}if(!i&&r.nodeType===f)return c(d)}({editableHost:e,container:r.startContainer,containerOffset:r.startOffset})}}},{key:"on",value:function(t,e){return this.dispatcher.on(t,e),this}},{key:"off",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.dispatcher.off.apply(this.dispatcher,e),this}},{key:"unload",value:function(){return this.dispatcher.unload(),this}},{key:"findClosestCursorOffset",value:function(t){var e=t.element,n=t.origCoordinates,r=t.requiredOnFirstLine,u=void 0!==r&&r,i=t.requiredOnLastLine;return function(t){var e=t.host,n=t.requiredOnFirstLine,r=t.requiredOnLastLine,u=t.positionX,i=e.ownerDocument.createRange();i.selectNodeContents(e);var o=i.getBoundingClientRect(),a=xi(e).reduce(function(t,e){return t+e.textContent.length},0),s=xi(e);if(0===a)return{wasFound:!1};for(var c,l={currentOffset:Math.floor(a/2),leftLimit:0,rightLimit:a},f=l.currentOffset,h=20;l.leftLimit<l.rightLimit&&h>0;){h=h-=1,f=l.currentOffset;var d=_i({textNodes:s,offset:l.currentOffset}).getBoundingClientRect();c=Math.abs(d.left-u),n&&o.top!==d.top?Ni(l):r&&o.bottom!==d.bottom?ji(l):u<d.left?Ni(l):ji(l)}var D=_i({textNodes:s,offset:l.currentOffset}).getBoundingClientRect(),v=Math.abs(D.left-u);return v<c&&(c=v,f=l.currentOffset),{distance:c,offset:f,wasFound:!0}}({host:e,requiredOnFirstLine:u,requiredOnLastLine:void 0!==i&&i,positionX:this.dispatcher.switchContext?this.dispatcher.switchContext.positionX:n.left})}}],n=[{key:"getGlobalConfig",value:function(){return u}},{key:"globalConfig",value:function(t){Object.assign(u,t),Je(u)}}],e&&Li(t.prototype,e),n&&Li(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();return Hi.parser=n,Hi.content=r,["focus","blur","flow","selection","cursor","newline","insert","split","merge","empty","change","switch","move","clipboard","paste","spellcheckUpdated","selectToBoundary"].forEach(function(t){Hi.prototype[t]=function(e){return this.on(t,e)}}),e=e.Editable,e})());
2
2
  //# sourceMappingURL=editable.js.map