/*! @yidun/web-highlighter v1.2.2 https://github.com/alienzhou/web-highlighter */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Highlighter=t():e.Highlighter=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.eventEmitter=t.INTERNAL_ERROR_EVENT=t.getStylesheet=t.getDefaultOptions=t.CAMEL_DATASET_IGNORE_NODE=t.CAMEL_DATASET_SPLIT_TYPE=t.CAMEL_DATASET_IDENTIFIER_EXTRA=t.CAMEL_DATASET_IDENTIFIER=t.DATASET_IGNORE_NODE=t.DATASET_SPLIT_TYPE=t.DATASET_IDENTIFIER_EXTRA=t.DATASET_IDENTIFIER=t.STYLESHEET_ID=t.LOCAL_STORE_KEY=t.ID_DIVISION=void 0;var o=r(n(10)),i=r(n(2));t.ID_DIVISION=";",t.LOCAL_STORE_KEY="highlight-mengshou",t.STYLESHEET_ID="highlight-mengshou-style",t.DATASET_IDENTIFIER="highlight-id",t.DATASET_IDENTIFIER_EXTRA="highlight-id-extra",t.DATASET_SPLIT_TYPE="highlight-split-type",t.DATASET_IGNORE_NODE="highlight-ignore-node",t.CAMEL_DATASET_IDENTIFIER=o.default(t.DATASET_IDENTIFIER),t.CAMEL_DATASET_IDENTIFIER_EXTRA=o.default(t.DATASET_IDENTIFIER_EXTRA),t.CAMEL_DATASET_SPLIT_TYPE=o.default(t.DATASET_SPLIT_TYPE),t.CAMEL_DATASET_IGNORE_NODE=o.default(t.DATASET_IGNORE_NODE);t.getDefaultOptions=function(){return{$root:document||document.documentElement,exceptSelectors:null,wrapTag:"span",verbose:!1,style:{className:"highlight-mengshou-wrap"}}};t.getStylesheet=function(){return"\n    ."+t.getDefaultOptions().style.className+" {\n        background: #ff9;\n        cursor: pointer;\n    }\n    ."+t.getDefaultOptions().style.className+".active {\n        background: #ffb;\n    }\n"},t.INTERNAL_ERROR_EVENT="error",t.eventEmitter=new i.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SelectionDirection=t.UserInputEvent=t.SelectedNodeType=t.CreateFrom=t.EventType=t.ERROR=t.SplitType=void 0,function(e){e.none="none",e.head="head",e.tail="tail",e.both="both"}(t.SplitType||(t.SplitType={})),function(e){e.DOM_TYPE_ERROR="[DOM] Receive wrong node type.",e.DOM_SELECTION_EMPTY="[DOM] The selection contains no dom node, may be you except them.",e.RANGE_INVALID="[RANGE] Got invalid dom range, can't convert to a valid highlight range.",e.RANGE_NODE_INVALID="[RANGE] Start or end node isn't a text node, it may occur an error.",e.DB_ID_DUPLICATE_ERROR="[STORE] Unique id conflict.",e.CACHE_SET_ERROR="[CACHE] Cache.data can't be set manually, please use .save().",e.SOURCE_TYPE_ERROR="[SOURCE] Object isn't a highlight source instance.",e.HIGHLIGHT_RANGE_FROZEN="[HIGHLIGHT_RANGE] A highlight range must be frozen before render.",e.HIGHLIGHT_SOURCE_RECREATE="[HIGHLIGHT_SOURCE] Recreate highlights from sources error.",e.HIGHLIGHT_SOURCE_NONE_RENDER="[HIGHLIGHT_SOURCE] This highlight source isn't rendered. May be the exception skips it or the dom structure has changed."}(t.ERROR||(t.ERROR={})),function(e){e.CREATE="selection:create",e.REMOVE="selection:remove",e.MODIFY="selection:modify",e.HOVER="selection:hover",e.HOVER_OUT="selection:hover-out",e.CLICK="selection:click"}(t.EventType||(t.EventType={})),function(e){e.STORE="from-store",e.INPUT="from-input"}(t.CreateFrom||(t.CreateFrom={})),function(e){e.text="text",e.span="span"}(t.SelectedNodeType||(t.SelectedNodeType={})),function(e){e.touchend="touchend",e.mouseup="mouseup",e.touchstart="touchstart",e.click="click",e.mouseover="mouseover"}(t.UserInputEvent||(t.UserInputEvent={})),function(e){e.Forward="forward",e.Backward="backward"}(t.SelectionDirection||(t.SelectionDirection={}))},function(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e};Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(){this.handlersMap=Object.create(null)}return e.prototype.on=function(e,t){return this.handlersMap[e]||(this.handlersMap[e]=[]),this.handlersMap[e].push(t),this},e.prototype.off=function(e,t){return this.handlersMap[e]&&this.handlersMap[e].splice(this.handlersMap[e].indexOf(t)>>>0,1),this},e.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return this.handlersMap[e]&&this.handlersMap[e].slice().forEach((function(e){e.apply(void 0,o(t))})),this},e}();t.default=i},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=r(n(5)),i=n(9),a=function(){function e(e,t,n,r,o,i){this.startMeta=e,this.endMeta=t,this.text=n,this.id=r,this.__isHighlightSource={},this.direction=o,i&&(this.extra=i)}return e.prototype.deSerialize=function(e,t){var n=i.getTextChildByOffset(e,this.startMeta.textOffset),r=i.getTextChildByOffset(e,this.endMeta.textOffset);if(!t.Serialize.Restore.isEmpty()){var a=t.Serialize.Restore.call(this,n,r)||[];n=a[0]||n,r=a[1]||r}return new o.default(n,r,this.text,this.id,this.direction,!0)},e}();t.default=a},function(e,t,n){"use strict";var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.hasClass=t.removeClass=t.addClass=t.addEventListener=t.removeEventListener=t.forEach=t.getHighlightById=t.getHighlightsByRoot=t.getExtraHighlightId=t.getHighlightId=t.isHighlightWrapNode=void 0;var o=n(0);t.isHighlightWrapNode=function(e){return!!e.dataset&&!!e.dataset[o.CAMEL_DATASET_IDENTIFIER]};var i=function(e,n){for(var r=!1,o=null;e;){if(t.isHighlightWrapNode(e)&&(o=e),e===n){r=!0;break}e=e.parentNode}return r?o:null};t.getHighlightId=function(e,t){return(e=i(e,t))?e.dataset[o.CAMEL_DATASET_IDENTIFIER]:""};t.getExtraHighlightId=function(e,t){return(e=i(e,t))?e.dataset[o.CAMEL_DATASET_IDENTIFIER_EXTRA].split(o.ID_DIVISION).filter((function(e){return e})):[]};t.getHighlightsByRoot=function(e,t){var n,i;Array.isArray(e)||(e=[e]);var a=[];try{for(var l=r(e),u=l.next();!u.done;u=l.next()){var s=u.value.querySelectorAll(t+"[data-"+o.DATASET_IDENTIFIER+"]");a.push.apply(a,s)}}catch(e){n={error:e}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}return a};t.getHighlightById=function(e,t,n){var i,a,l=[],u=new RegExp("("+t+"\\"+o.ID_DIVISION+"|\\"+o.ID_DIVISION+"?"+t+"$)"),s=e.querySelectorAll(n+"[data-"+o.DATASET_IDENTIFIER+"]");try{for(var d=r(s),c=d.next();!c.done;c=d.next()){var f=c.value;if(f.dataset[o.CAMEL_DATASET_IDENTIFIER]!==t){var h=f.dataset[o.CAMEL_DATASET_IDENTIFIER_EXTRA];u.test(h)&&l.push(f)}else l.push(f)}}catch(e){i={error:e}}finally{try{c&&!c.done&&(a=d.return)&&a.call(d)}finally{if(i)throw i.error}}return l};t.forEach=function(e,t){for(var n=0;n<e.length;n++)t(e[n],n,e)};t.removeEventListener=function(e,t,n){e.removeEventListener(t,n)};t.addEventListener=function(e,n,r){return e.addEventListener(n,r),function(){t.removeEventListener(e,n,r)}};t.addClass=function(e,t){e.classList.add(t)};t.removeClass=function(e,t){e.classList.remove(t)};t.hasClass=function(e,t){return e.classList.contains(t)}},function(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=o(n(3)),a=n(1),l=n(11),u=o(n(6)),s=n(12),d=n(0),c=function(){function e(e,t,n,r,o,i){void 0===i&&(i=!1),3===e.$node.nodeType&&3===t.$node.nodeType||d.eventEmitter.emit(d.INTERNAL_ERROR_EVENT,{type:a.ERROR.RANGE_NODE_INVALID}),this.start=s.formatDomNode(e),this.end=s.formatDomNode(t),this.text=n,this.frozen=i,this.id=r,this.direction=o}return e.fromSelection=function(t,n){var o=l.getDomRange();if(!o)return null;var i=r(o,2),a=i[0],d=i[1],c={$node:a.startContainer,offset:a.startOffset},f={$node:a.endContainer,offset:a.endOffset},h=s.getSelectionText(t,c,f),p=n.call(c,f,h);return new e(c,f,h,p=null!=p?p:u.default(),d)},e.prototype.serialize=function(e,t){var n,r=s.getDomMeta(this.start.$node,this.start.offset,e),o=s.getDomMeta(this.end.$node,this.end.offset,e);return t.Serialize.RecordInfo.isEmpty()||(n=t.Serialize.RecordInfo.call(this.start,this.end,e)),this.frozen=!0,new i.default(r,o,this.text,this.id,this.direction,n)},e.removeDomRange=l.removeSelection,e}();t.default=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function e(t){return t?(t^16*Math.random()>>t/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/gu,e)}},function(e,t,n){e.exports=n(8)},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var l=a(n(2)),u=a(n(5)),s=a(n(3)),d=a(n(6)),c=a(n(13)),f=a(n(14)),h=a(n(16)),p=a(n(17)),E=n(0),_=n(1),v=n(4),T=function(e){function t(t){var n=e.call(this)||this;n.event=f.default(),n.run=function(){return v.addEventListener(n.options.$root,n.event.PointerEnd,n._handleSelection)},n.stop=function(){v.removeEventListener(n.options.$root,n.event.PointerEnd,n._handleSelection)},n.addClass=function(e,t){n.getDoms(t).forEach((function(t){v.addClass(t,e)}))},n.removeClass=function(e,t){n.getDoms(t).forEach((function(t){v.removeClass(t,e)}))},n.getIdByDom=function(e){return v.getHighlightId(e,n.options.$root)},n.getExtraIdByDom=function(e){return v.getExtraHighlightId(e,n.options.$root)},n.getDoms=function(e){return e?v.getHighlightById(n.options.$root,e,n.options.wrapTag):v.getHighlightsByRoot(n.options.$root,n.options.wrapTag)},n.dispose=function(){var e=n.options.$root;v.removeEventListener(e,n.event.PointerOver,n._handleHighlightHover),v.removeEventListener(e,n.event.PointerEnd,n._handleSelection),v.removeEventListener(e,n.event.PointerTap,n._handleHighlightClick),E.eventEmitter.off(E.INTERNAL_ERROR_EVENT,n._handleError),n.removeAll()},n.setOption=function(e){n.options=i(i({},n.options),e),n.painter=new p.default({$root:n.options.$root,wrapTag:n.options.wrapTag,className:n.options.style.className,exceptSelectors:n.options.exceptSelectors},n.hooks)},n.fromRange=function(e,t){var r={$node:e.startContainer,offset:e.startOffset},o={$node:e.endContainer,offset:e.endOffset},i=e.toString(),a=n.hooks.Render.UUID.call(r,o,i);a=null!=a?a:d.default();var l=new u.default(r,o,i,a,t);return l?n._highlightFromHRange(l):(E.eventEmitter.emit(E.INTERNAL_ERROR_EVENT,{type:_.ERROR.RANGE_INVALID}),null)},n.fromStore=function(e,t,r,o,i,a){try{var l=new s.default(e,t,r,o,i,a);return n._highlightFromHSource(l),l}catch(n){return E.eventEmitter.emit(E.INTERNAL_ERROR_EVENT,{type:_.ERROR.HIGHLIGHT_SOURCE_RECREATE,detail:{err:n,id:o,text:r,start:e,end:t}}),null}},n._getHooks=function(){return{Render:{UUID:new c.default("Render.UUID"),SelectedNodes:new c.default("Render.SelectedNodes"),WrapNode:new c.default("Render.WrapNode")},Serialize:{Restore:new c.default("Serialize.Restore"),RecordInfo:new c.default("Serialize.RecordInfo")},Remove:{UpdateNodes:new c.default("Remove.UpdateNodes")}}},n._highlightFromHRange=function(e){var t=e.serialize(n.options.$root,n.hooks);return 0===n.painter.highlightRange(e).length?(E.eventEmitter.emit(E.INTERNAL_ERROR_EVENT,{type:_.ERROR.DOM_SELECTION_EMPTY}),null):(n.cache.save(t),n.emit(_.EventType.CREATE,{sources:[t],type:_.CreateFrom.INPUT},n),t)},n._handleSelection=function(){var e=u.default.fromSelection(n.options.$root,n.hooks.Render.UUID);e&&(n._highlightFromHRange(e),u.default.removeDomRange())},n._handleHighlightHover=function(e){var t=e.target;if(!v.isHighlightWrapNode(t))return n._hoverId&&n.emit(_.EventType.HOVER_OUT,{id:n._hoverId},n,e),void(n._hoverId=null);var r=v.getHighlightId(t,n.options.$root);n._hoverId!==r&&(n._hoverId&&n.emit(_.EventType.HOVER_OUT,{id:n._hoverId},n,e),n._hoverId=r,n.emit(_.EventType.HOVER,{id:n._hoverId},n,e))},n._handleError=function(e){n.options.verbose&&console.warn(e)},n._handleHighlightClick=function(e){var t=e.target;if(v.isHighlightWrapNode(t)){var r=v.getHighlightId(t,n.options.$root);n.emit(_.EventType.CLICK,{id:r},n,e)}},n.options=E.getDefaultOptions(),n.hooks=n._getHooks(),n.setOption(t),n.cache=new h.default;var r=n.options.$root;return v.addEventListener(r,n.event.PointerOver,n._handleHighlightHover),v.addEventListener(r,n.event.PointerTap,n._handleHighlightClick),E.eventEmitter.on(E.INTERNAL_ERROR_EVENT,n._handleError),n}return o(t,e),t.prototype.remove=function(e){if(e){var t=this.painter.removeHighlight(e);this.cache.remove(e),t&&this.emit(_.EventType.REMOVE,{ids:[e]},this)}},t.prototype.removeAll=function(){this.painter.removeAllHighlight();var e=this.cache.removeAll();this.emit(_.EventType.REMOVE,{ids:e},this)},t.prototype._highlightFromHSource=function(e){void 0===e&&(e=[]);var t=this.painter.highlightSource(e);this.emit(_.EventType.CREATE,{sources:t,type:_.CreateFrom.STORE},this),this.cache.save(e)},t.event=_.EventType,t.isHighlightWrapNode=v.isHighlightWrapNode,t.isHighlightSource=function(e){return!!e.__isHighlightSource},t}(l.default);t.default=T},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getTextChildByOffset=void 0;var r=n(0);t.getTextChildByOffset=function(e,t){for(var n,o=[e],i=null,a=0,l=0;i=o.pop();){for(var u=i.childNodes,s=u.length-1;s>=0;s--){(null===(n=u[s].dataset)||void 0===n?void 0:n[r.CAMEL_DATASET_IGNORE_NODE])||o.push(u[s])}if(3===i.nodeType&&(l=t-a,(a+=i.textContent.length)>=t))break}return i||(i=e),{$node:i,offset:l}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return e.split("-").reduce((function(e,t,n){return e+(0===n?t:t[0].toUpperCase()+t.slice(1))}),"")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.removeSelection=t.getDomRange=t.getSelectionDirection=void 0;var r=n(1);t.getSelectionDirection=function(e){var t=e.anchorNode.compareDocumentPosition(e.focusNode);return!t&&e.anchorOffset>e.focusOffset||t===Node.DOCUMENT_POSITION_PRECEDING?r.SelectionDirection.Backward:r.SelectionDirection.Forward};t.getDomRange=function(){var e=window.getSelection();if(e.isCollapsed)return console.debug("no text selected"),null;var n=t.getSelectionDirection(e);return[e.getRangeAt(0),n]};t.removeSelection=function(){window.getSelection().removeAllRanges()}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatDomNode=t.getDomMeta=t.getSelectionText=void 0;var r=n(0);t.getSelectionText=function(e,t,n){var o,i=[e],a=null;if(t.$node===n.$node&&3===t.$node.nodeType)return t.$node.textContent.slice(t.offset,n.offset);for(var l="",u=!1;a=i.pop();){for(var s=a.childNodes,d=s.length-1;d>=0;d--){(null===(o=s[d].dataset)||void 0===o?void 0:o[r.CAMEL_DATASET_IGNORE_NODE])||i.push(s[d])}if(a===t.$node)l+=a.textContent.slice(t.offset),u=!0;else{if(a===n.$node){l+=a.textContent.slice(0,n.offset);break}3===a.nodeType&&u&&(l+=a.textContent)}}return l};t.getDomMeta=function(e,t,n){return{textOffset:function(e,t){for(var n,o=[e],i=null,a=0;i=o.pop();){for(var l=i.childNodes,u=l.length-1;u>=0;u--){(null===(n=l[u].dataset)||void 0===n?void 0:n[r.CAMEL_DATASET_IGNORE_NODE])||o.push(l[u])}if(3===i.nodeType&&i!==t)a+=i.textContent.length;else if(3===i.nodeType)break}return a}(n,e)+t}};t.formatDomNode=function(e){return 3===e.$node.nodeType||4===e.$node.nodeType||8===e.$node.nodeType?e:{$node:e.$node.childNodes[e.offset],offset:0}}},function(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e};Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e){this.name="",this.ops=[],this.name=e}return e.prototype.tap=function(e){var t=this;return this.ops.includes(e)||this.ops.push(e),function(){t.remove(e)}},e.prototype.remove=function(e){var t=this.ops.indexOf(e);t<0||this.ops.splice(t,1)},e.prototype.isEmpty=function(){return 0===this.ops.length},e.prototype.call=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return this.ops.forEach((function(n){e=n.apply(void 0,o(t))})),e},e}();t.default=i},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(n(15));t.default=function(){var e=i.default(window.navigator.userAgent);return{PointerEnd:e?o.UserInputEvent.touchend:o.UserInputEvent.mouseup,PointerTap:e?o.UserInputEvent.touchstart:o.UserInputEvent.click,PointerOver:e?o.UserInputEvent.touchstart:o.UserInputEvent.mouseover}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=/Android|iPhone|BlackBerry|BB10|Opera Mini|Phone|Mobile|Silk|Windows Phone|Mobile(?:.+)Firefox\b/iu;t.default=function(e){return r.test(e)}},function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var l=a(n(2)),u=n(1),s=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._data=new Map,t}return o(t,e),Object.defineProperty(t.prototype,"data",{get:function(){return this.getAll()},set:function(e){throw u.ERROR.CACHE_SET_ERROR},enumerable:!1,configurable:!0}),t.prototype.save=function(e){var t=this;Array.isArray(e)?e.forEach((function(e){return t._data.set(e.id,e)})):this._data.set(e.id,e)},t.prototype.get=function(e){return this._data.get(e)},t.prototype.remove=function(e){this._data.delete(e)},t.prototype.getAll=function(){var e,t,n=[];try{for(var r=i(this._data),o=r.next();!o.done;o=r.next()){var a=o.value;n.push(a[1])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return n},t.prototype.removeAll=function(){var e,t,n=[];try{for(var r=i(this._data),o=r.next();!o.done;o=r.next()){var a=o.value;n.push(a[0])}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return this._data=new Map,n},t}(l.default);t.default=s},function(e,t,n){"use strict";var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=o(n(3)),a=n(18),l=n(4),u=n(1),s=n(20),d=n(0),c=function(){function e(e,t){this.options={$root:e.$root,wrapTag:e.wrapTag,exceptSelectors:e.exceptSelectors,className:e.className},this.hooks=t,s.initDefaultStylesheet()}return e.prototype.highlightRange=function(e){var t=this;if(!e.frozen)throw u.ERROR.HIGHLIGHT_RANGE_FROZEN;var n=this.options,r=n.$root,o=n.className,i=n.exceptSelectors,l=this.hooks,s=a.getSelectedNodes(r,e.start,e.end,i);return l.Render.SelectedNodes.isEmpty()||(s=l.Render.SelectedNodes.call(e.id,s)||[]),s.map((function(n){var r=a.wrapHighlight(n,e,o,t.options.wrapTag);return l.Render.WrapNode.isEmpty()||(r=l.Render.WrapNode.call(e.id,r)),r}))},e.prototype.highlightSource=function(e){var t=this,n=Array.isArray(e)?e:[e],r=[];return n.forEach((function(e){if(e instanceof i.default){var n=e.deSerialize(t.options.$root,t.hooks);t.highlightRange(n).length>0?r.push(e):d.eventEmitter.emit(d.INTERNAL_ERROR_EVENT,{type:u.ERROR.HIGHLIGHT_SOURCE_NONE_RENDER,detail:e})}else d.eventEmitter.emit(d.INTERNAL_ERROR_EVENT,{type:u.ERROR.SOURCE_TYPE_ERROR})})),r},e.prototype.removeHighlight=function(e){var t,n,o=new RegExp("("+e+"\\"+d.ID_DIVISION+"|\\"+d.ID_DIVISION+"?"+e+"$)"),i=this.hooks,u=this.options.wrapTag,s=document.querySelectorAll(u+"[data-"+d.DATASET_IDENTIFIER+"]"),c=[],f=[],h=[];try{for(var p=r(s),E=p.next();!E.done;E=p.next()){var _=E.value,v=_.dataset[d.CAMEL_DATASET_IDENTIFIER],T=_.dataset[d.CAMEL_DATASET_IDENTIFIER_EXTRA];v!==e||T?v===e?f.push(_):v!==e&&o.test(T)&&h.push(_):c.push(_)}}catch(e){t={error:e}}finally{try{E&&!E.done&&(n=p.return)&&n.call(p)}finally{if(t)throw t.error}}return c.forEach((function(t){var n=t.parentNode,r=document.createDocumentFragment();l.forEach(t.childNodes,(function(e){return r.appendChild(e.cloneNode(!1))}));var o=t.previousSibling,u=t.nextSibling;n.replaceChild(r,t),a.normalizeSiblingText(o,!0),a.normalizeSiblingText(u,!1),i.Remove.UpdateNodes.call(e,t,"remove")})),f.forEach((function(t){var n=t.dataset,r=n[d.CAMEL_DATASET_IDENTIFIER_EXTRA].split(d.ID_DIVISION);n[d.CAMEL_DATASET_IDENTIFIER]=r.shift(),n[d.CAMEL_DATASET_IDENTIFIER_EXTRA]=r.join(d.ID_DIVISION),i.Remove.UpdateNodes.call(e,t,"id-update")})),h.forEach((function(t){var n=t.dataset[d.CAMEL_DATASET_IDENTIFIER_EXTRA];t.dataset[d.CAMEL_DATASET_IDENTIFIER_EXTRA]=n.replace(o,""),i.Remove.UpdateNodes.call(e,t,"extra-update")})),c.length+f.length+h.length!==0},e.prototype.removeAllHighlight=function(){var e=this.options,t=e.wrapTag,n=e.$root;l.getHighlightsByRoot(n,t).forEach((function(e){var t=e.parentNode,n=document.createDocumentFragment();l.forEach(e.childNodes,(function(e){return n.appendChild(e.cloneNode(!1))})),t.replaceChild(n,e)}))},e}();t.default=c},function(e,t,n){"use strict";var r=this&&this.__read||function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e};Object.defineProperty(t,"__esModule",{value:!0}),t.normalizeSiblingText=t.wrapHighlight=t.getSelectedNodes=void 0;var i=n(1),a=n(4),l=n(0),u=n(19),s=function(e,t){if(!e)return!1;if(t.startsWith(".")){var n=t.replace(/^\./u,"");return e&&a.hasClass(e,n)}if(t.startsWith("#")){var r=t.replace(/^#/u,"");return e&&e.id===r}var o=t.toUpperCase();return e&&e.tagName===o};t.getSelectedNodes=function(e,t,n,r){var o=t.$node,a=n.$node,l=t.offset,u=n.offset;if(o===a&&o instanceof Text)return function(e,t,n,r){for(var o=e,a=function(e){return null==r?void 0:r.some((function(t){return s(e,t)}))};o;){if(1===o.nodeType&&a(o))return[];o=o.parentNode}e.splitText(t);var l=e.nextSibling;return l.splitText(n-t),[{$node:l,type:i.SelectedNodeType.text,splitType:i.SplitType.both}]}(o,l,u,r);for(var d=[e],c=[],f=function(e){return null==r?void 0:r.some((function(t){return s(e,t)}))},h=!1,p=null;p=d.pop();)if(1!==p.nodeType||!f(p)){for(var E=p.childNodes,_=E.length-1;_>=0;_--)d.push(E[_]);if(p===o){if(3===p.nodeType){p.splitText(l);var v=p.nextSibling;c.push({$node:v,type:i.SelectedNodeType.text,splitType:i.SplitType.head})}h=!0}else{if(p===a){if(3===p.nodeType)(v=p).splitText(u),c.push({$node:v,type:i.SelectedNodeType.text,splitType:i.SplitType.tail});break}h&&3===p.nodeType&&c.push({$node:p,type:i.SelectedNodeType.text,splitType:i.SplitType.none})}}return c};var d=function(e,t){var n=Array.isArray(t)?t:[t];return(n=0===n.length?[l.getDefaultOptions().style.className]:n).forEach((function(t){a.addClass(e,t)})),e},c=function(e){return!e||!e.textContent};t.wrapHighlight=function(e,t,n,r){var s=e.$node.parentNode,f=e.$node.previousSibling,h=e.$node.nextSibling;return a.isHighlightWrapNode(s)?!a.isHighlightWrapNode(s)||c(f)&&c(h)?function(e,t,n){var r=e.$node.parentNode,o=r;d(o,n);var i=r.dataset,a=i[l.CAMEL_DATASET_IDENTIFIER];return i[l.CAMEL_DATASET_IDENTIFIER]=t.id,i[l.CAMEL_DATASET_IDENTIFIER_EXTRA]=i[l.CAMEL_DATASET_IDENTIFIER_EXTRA]?a+l.ID_DIVISION+i[l.CAMEL_DATASET_IDENTIFIER_EXTRA]:a,o}(e,t,n):function(e,t,n,r){var s=document.createElement(r),c=e.$node.parentNode,f=e.$node.previousSibling,h=e.$node.nextSibling,p=document.createDocumentFragment(),E=c.dataset[l.CAMEL_DATASET_IDENTIFIER],_=c.dataset[l.CAMEL_DATASET_IDENTIFIER_EXTRA],v=_?E+l.ID_DIVISION+_:E;s.setAttribute("data-"+l.DATASET_IDENTIFIER,t.id),s.setAttribute("data-"+l.DATASET_IDENTIFIER_EXTRA,v),s.appendChild(e.$node.cloneNode(!1));var T,g=!1,y=!1;f&&((I=c.cloneNode(!1)).textContent=f.textContent,p.appendChild(I),g=!0);var I,R=[];(a.isHighlightWrapNode(c)&&c.classList.forEach((function(e){return R.push(e)})),Array.isArray(n)?R.push.apply(R,o(n)):R.push(n),d(s,u.unique(R)),p.appendChild(s),h)&&((I=c.cloneNode(!1)).textContent=h.textContent,p.appendChild(I),y=!0);return T=g&&y?i.SplitType.both:g?i.SplitType.head:y?i.SplitType.tail:i.SplitType.none,s.setAttribute("data-"+l.DATASET_SPLIT_TYPE,T),c.parentNode.replaceChild(p,c),s}(e,t,n,r):function(e,t,n,r){var o=document.createElement(r);return d(o,n),o.appendChild(e.$node.cloneNode(!1)),e.$node.parentNode.replaceChild(o,e.$node),o.setAttribute("data-"+l.DATASET_IDENTIFIER,t.id),o.setAttribute("data-"+l.DATASET_SPLIT_TYPE,e.splitType),o.setAttribute("data-"+l.DATASET_IDENTIFIER_EXTRA,""),o}(e,t,n,r)};t.normalizeSiblingText=function(e,t){if(void 0===t&&(t=!0),e&&3===e.nodeType){var n=t?e.nextSibling:e.previousSibling;if(3===n.nodeType){var r=n.nodeValue;e.nodeValue=t?e.nodeValue+r:r+e.nodeValue,n.parentNode.removeChild(n)}}}},function(e,t,n){"use strict";var r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.unique=void 0;t.unique=function(e){var t,n,o=[];try{for(var i=r(e),a=i.next();!a.done;a=i.next()){var l=a.value;o.includes(l)||o.push(l)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return o}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.initDefaultStylesheet=void 0;var r=n(0);t.initDefaultStylesheet=function(){var e=r.STYLESHEET_ID,t=document.getElementById(e);if(!t){var n=document.createTextNode(r.getStylesheet());(t=document.createElement("style")).id=e,t.appendChild(n),document.head.appendChild(t)}return t}}]).default}));
//# sourceMappingURL=web-highlighter.min.js.map