1/** 2 * Bundled by jsDelivr using Rollup v4.62.2 and esbuild v0.28.1. 3 * Original file: /npm/@rangy/[email protected]/lib/esm5/index.js 4 * 5 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files 6 */ 7import*as u from"@rangy/core";import{Module as b,dom as s}from"@rangy/core";function D(t){for(var e=[],n=0,a=t.length,r;n<a;++n)r=t.charCodeAt(n),r<128?e.push(r):r<2048?e.push(r>>6|192,r&63|128):e.push(r>>12|224,r>>6&63|128,r&63|128);return e}var m=null;function T(){for(var t=[],e=0,n,a;e<256;++e){for(a=e,n=8;n--;)(a&1)==1?a=a>>>1^3988292384:a>>>=1;t[e]=a>>>0}return t}function U(){return m||(m=T()),m}function y(t){for(var e=D(t),n=-1,a=U(),r=0,i=e.length,l;r<i;++r)l=(n^e[r])&255,n=n>>>8^a[l];return(n^-1)>>>0}var d=new b("Serializer",["WrappedSelection"]),p="undefined";(typeof encodeURIComponent==p||typeof decodeURIComponent==p)&&d.fail("encodeURIComponent and/or decodeURIComponent method is missing");function C(t){return t.replace(/</g,"<").replace(/>/g,">")}function h(t,e){e=e||[];var n=t.nodeType,a=t.childNodes,r=a.length,i=[n,t.nodeName,r].join(":"),l="",o="";switch(n){case 3:l=C(t.nodeValue);break;case 8:l="<!--"+C(t.nodeValue)+"-->";break;default:l="<"+i+">",o="</>";break}l&&e.push(l);for(var c=0;c<r;++c)h(a[c],e);return o&&e.push(o),e}function f(t){var e=h(t).join("");return y(e).toString(16)}function g(t,e,n){var a=[],r=t;for(n=n||s.getDocument(t).documentElement;r&&r!=n;)a.push(s.getNodeIndex(r)),r=r.parentNode;return a.join("/")+":"+e}function v(t,e,n){e||(e=(n||document).documentElement);for(var a=t.split(":"),r=e,i=a[0]?a[0].split("/"):[],l=i.length,o;l--;)if(o=parseInt(i[l],10),o<r.childNodes.length)r=r.childNodes[o];else throw d.createError("deserializePosition() failed: node "+s.inspectNode(r)+" has no child with index "+o+", "+l);return new s.DomPosition(r,parseInt(a[1],10))}function z(t,e,n){if(n=n||u.DomRange.getRangeDocument(t).documentElement,!s.isOrIsAncestorOf(n,t.commonAncestorContainer))throw d.createError("serializeRange(): range "+t.inspect()+" is not wholly contained within specified root node "+s.inspectNode(n));var a=g(t.startContainer,t.startOffset,n)+","+g(t.endContainer,t.endOffset,n);return e||(a+="{"+f(n)+"}"),a}var R=/^([^,]+),([^,\{]+)(\{([^}]+)\})?$/;function S(t,e,n){e?n=n||s.getDocument(e):(n=n||document,e=n.documentElement);var a=R.exec(t),r=a[4];if(r){var i=f(e);if(r!==i)throw d.createError("deserializeRange(): checksums of serialized range root node ("+r+") and target root node ("+i+") do not match")}var l=v(a[1],e,n),o=v(a[2],e,n),c=u.createRange(n);return c.setStartAndEnd(l.node,l.offset,o.node,o.offset),c}function I(t,e,n){e||(e=(n||document).documentElement);var a=R.exec(t),r=a[3];return!r||r===f(e)}function x(t,e,n){t=u.getSelection(t);for(var a=t.getAllRanges(),r=[],i=0,l=a.length;i<l;++i)r[i]=z(a[i],e,n);return r.join("|")}function E(t,e,n){e?n=n||s.getWindow(e):(n=n||window,e=n.document.documentElement);for(var a=t.split("|"),r=u.getSelection(n),i=[],l=0,o=a.length;l<o;++l)i[l]=S(a[l],e,n.document);return r.setRanges(i),r}function F(t,e,n){var a;e?a=n?n.document:s.getDocument(e):(n=n||window,e=n.document.documentElement);for(var r=t.split("|"),i=0,l=r.length;i<l;++i)if(!I(r[i],e,a))return!1;return!0}var k="rangySerializedSelection";function w(t){for(var e=t.split(/[;,]/),n=0,a=e.length,r,i;n<a;++n)if(r=e[n].split("="),r[0].replace(/^\s+/,"")==k&&(i=r[1],i))return decodeURIComponent(i.replace(/\s+$/,""));return null}function A(t){t=t||window;var e=w(t.document.cookie);e&&E(e,t.doc)}function j(t,e){t=t||window,e=typeof e=="object"?e:{};var n=e.expires?";expires="+e.expires.toUTCString():"",a=e.path?";path="+e.path:"",r=e.domain?";domain="+e.domain:"",i=e.secure?";secure":"",l=x(u.getSelection(t));t.document.cookie=encodeURIComponent(k)+"="+encodeURIComponent(l)+n+a+r+i}export{I as canDeserializeRange,F as canDeserializeSelection,v as deserializePosition,S as deserializeRange,E as deserializeSelection,f as getElementChecksum,h as nodeToInfoString,A as restoreSelectionFromCookie,j as saveSelectionCookie,g as serializePosition,z as serializeRange,x as serializeSelection};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.