/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/selection-ranges@4.1.1/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var componentXor,hasRequiredComponentXor,componentProps,hasRequiredComponentProps,domIterator,hasRequiredDomIterator;function requireComponentXor(){if(hasRequiredComponentXor)return componentXor;return hasRequiredComponentXor=1,componentXor=function(t,e){return t^e}}function requireComponentProps(){if(hasRequiredComponentProps)return componentProps;hasRequiredComponentProps=1;var t=/\b(Array|Date|Object|Math|JSON)\b/g;return componentProps=function(e,n){var r=function(t){for(var e=[],n=0;n<t.length;n++)~e.indexOf(t[n])||e.push(t[n]);return e}(function(e){return e.replace(/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\//g,"").replace(t,"").match(/[a-zA-Z_]\w*/g)||[]}(e));return n&&"string"==typeof n&&(n=function(t){return function(e){return t+e}}(n)),n?function(t,e,n){var r=/\.\w+|\w+ *\(|"[^"]*"|'[^']*'|\/([^/]+)\/|[a-zA-Z_]\w*/g;return t.replace(r,(function(t){return"("==t[t.length-1]||~e.indexOf(t)?n(t):t}))}(e,r,n):r},componentProps}function requireDomIterator(){if(hasRequiredDomIterator)return domIterator;hasRequiredDomIterator=1;var t=requireComponentXor(),e=requireComponentProps();function n(t,e){if(!(this instanceof n))return new n(t,e);if(this.node=this.start=this.peeked=t,this.root=e,this.closingTag=!1,this._revisit=!0,this._selects=[],this._rejects=[],t&&this.higher(t))throw new Error("root must be a parent or ancestor to node")}function r(e,n){var r="nextSibling"==e;return function(o,i,s){o=this.compile(o),i=i&&i>0?i:1;for(var a=this.node,u=this.closingTag,c=this._revisit;a;){if(t(r,u)&&a[n])a=a[n],u=!r;else if(1==a.nodeType&&!a[n]&&t(r,u)){if(u=r,!c)continue}else if(a[e])a=a[e],u=!r;else if(a=a.parentNode,u=r,!c)continue;if(!a||this.higher(a,this.root))break;if(o(a)&&this.selects(a,s)&&this.rejects(a,s)){if(--i)continue;return s||(this.node=a),this.closingTag=u,a}}return null}}return domIterator=n,n.prototype.reset=function(t){return this.node=t||this.start,this},n.prototype.revisit=function(t){return this._revisit=null==t||t,this},n.prototype.opening=function(){return 1==this.node.nodeType&&(this.closingTag=!1),this},n.prototype.atOpening=function(){return!this.closingTag},n.prototype.closing=function(){return 1==this.node.nodeType&&(this.closingTag=!0),this},n.prototype.atClosing=function(){return this.closingTag},n.prototype.next=r("nextSibling","firstChild"),n.prototype.previous=n.prototype.prev=r("previousSibling","lastChild"),n.prototype.select=function(t){return t=this.compile(t),this._selects.push(t),this},n.prototype.selects=function(t,e){var n=this._selects,r=n.length;if(!r)return!0;for(var o=0;o<r;o++)if(n[o].call(this,t,e))return!0;return!1},n.prototype.reject=function(t){return t=this.compile(t),this._rejects.push(t),this},n.prototype.rejects=function(t,e){var n=this._rejects,r=n.length;if(!r)return!0;for(var o=0;o<r;o++)if(n[o].call(this,t,e))return!1;return!0},n.prototype.higher=function(t){var e=this.root;if(!e)return!1;for(t=t.parentNode;t&&t!=e;)t=t.parentNode;return t!=e},n.prototype.compile=function(t){switch(typeof t){case"number":return function(e){return t==e.nodeType};case"string":return new Function("node","Object.freeze(node); return "+e(t,"node."));case"function":return t;default:return function(){return!0}}},n.prototype.peak=n.prototype.peek=function(t,e){return 1==arguments.length&&(e=t,t=!0),(e=null==e?1:e)?e>0?this.next(t,e,!0):this.prev(t,Math.abs(e),!0):this.node},n.prototype.use=function(t){return t(this),this},domIterator}var domIteratorExports=requireDomIterator(),iterator=getDefaultExportFromCjs(domIteratorExports),selection=window.getSelection();function applyRange(t){selection?.removeAllRanges(),selection?.addRange(t)}function getWindowSelection(){return selection}function isSelected(t){if(!selection?.rangeCount)return null;var e=selection.focusNode;return isText(e)&&(e=e.parentNode),t==e||t.contains(e)}function setRange(t,e){applyRange(createRange(t,e))}function getRange(t){if(!isSelected(t))return null;var e,n,r=selection.getRangeAt(0),o=r.startContainer,i=r.endContainer,s=r.startOffset,a=r.endOffset,u=iterator(t.firstChild,t),c=u.node,p=!1,f=0;function l(t,e){return 1===arguments.length&&(e=t),t.parentNode===i&&e==i.childNodes[a]}function h(t,e){return 1===arguments.length&&(e=t),t.parentNode===o&&e==o.childNodes[s]}for(;c&&(h(c)&&!p&&(n=f),!l(c))&&(!isBr(c)||i!==c);){if(p||(isBr(c)||e&&e.nextSibling==c&&(isDiv(c)||isParagraph(c)))&&f++,isText(c)){if(o===c&&(n=f+s),i===c){f+=a;break}f+=c.textContent.length}if((isText(c)||p)&&(h(c,c.nextSibling)&&(n=f),l(c,c.nextSibling)))break;e=c,c=u.next(),p=u.closingTag}return{start:void 0===n?f:n,end:f}}function annotateRange(t,e){return e.start===e.end?t.substring(0,e.start)+"|"+t.substring(e.start):t.substring(0,e.start)+"<"+t.substring(e.start,e.end)+">"+t.substring(e.end)}function createRange(t,e){for(var n,r=e.start,o=e.end,i=document.createRange(),s=iterator(t.firstChild,t),a=s.node,u=!1,c=0;a;){if(c===r&&(u?i.setStartAfter(a):i.setStartBefore(a)),c===o)return u?i.setEndAfter(a):i.setEndBefore(a),i;if(u||(isBr(a)||a.previousSibling&&(isDiv(a)||isParagraph(a)))&&c++,isText(a)){if(n=a.textContent.length,c<=r&&c+n>r&&i.setStart(a,r-c),c+n>o)return i.setEnd(a,o-c),i;c+=n}a=s.next(),u=s.closingTag}return c<=r&&(t.lastChild?i.setStartAfter(t.lastChild):i.setStart(t,0)),t.lastChild?i.setEndAfter(t.lastChild):i.setEnd(t,0),i}function isText(t){return 3===t.nodeType}function isBr(t){return 1===t.nodeType&&"BR"===t.nodeName}function isDiv(t){return 1===t.nodeType&&"DIV"===t.nodeName}function isParagraph(t){return 1===t.nodeType&&"P"===t.nodeName}export{annotateRange,applyRange,getRange,getWindowSelection,isSelected,setRange};
//# sourceMappingURL=/sm/5005ac1691688db5951e504297edca439feb67edb1e25e5aa3cc43a8aa2bb166.map