@blockspark/chat-widget 1.0.10 → 1.0.12

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.
@@ -455,13 +455,13 @@ let pubCache;
455
455
  const isKeyObject = (key) => {
456
456
  return key?.[Symbol.toStringTag] === "KeyObject";
457
457
  };
458
- const importAndCache = async (cache, key, jwk, alg, freeze = false) => {
458
+ const importAndCache = async (cache, key, jwk, alg, freeze2 = false) => {
459
459
  let cached = cache.get(key);
460
460
  if (cached?.[alg]) {
461
461
  return cached[alg];
462
462
  }
463
463
  const cryptoKey = await parse({ ...jwk, alg });
464
- if (freeze)
464
+ if (freeze2)
465
465
  Object.freeze(key);
466
466
  if (!cached) {
467
467
  cache.set(key, { [alg]: cryptoKey });
@@ -1783,1029 +1783,1016 @@ class ChatService {
1783
1783
  function createChatService(config) {
1784
1784
  return new ChatService(config);
1785
1785
  }
1786
- function getDefaultExportFromCjs(x) {
1787
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1788
- }
1789
1786
  /*! @license DOMPurify 3.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.1/LICENSE */
1790
- var purify_cjs;
1791
- var hasRequiredPurify_cjs;
1792
- function requirePurify_cjs() {
1793
- if (hasRequiredPurify_cjs) return purify_cjs;
1794
- hasRequiredPurify_cjs = 1;
1795
- const {
1796
- entries,
1797
- setPrototypeOf,
1798
- isFrozen,
1799
- getPrototypeOf,
1800
- getOwnPropertyDescriptor
1801
- } = Object;
1802
- let {
1803
- freeze,
1804
- seal,
1805
- create
1806
- } = Object;
1807
- let {
1808
- apply,
1809
- construct
1810
- } = typeof Reflect !== "undefined" && Reflect;
1811
- if (!freeze) {
1812
- freeze = function freeze2(x) {
1813
- return x;
1814
- };
1815
- }
1816
- if (!seal) {
1817
- seal = function seal2(x) {
1818
- return x;
1819
- };
1820
- }
1821
- if (!apply) {
1822
- apply = function apply2(func, thisArg) {
1823
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1824
- args[_key - 2] = arguments[_key];
1825
- }
1826
- return func.apply(thisArg, args);
1827
- };
1828
- }
1829
- if (!construct) {
1830
- construct = function construct2(Func) {
1831
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1832
- args[_key2 - 1] = arguments[_key2];
1833
- }
1834
- return new Func(...args);
1835
- };
1836
- }
1837
- const arrayForEach = unapply(Array.prototype.forEach);
1838
- const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
1839
- const arrayPop = unapply(Array.prototype.pop);
1840
- const arrayPush = unapply(Array.prototype.push);
1841
- const arraySplice = unapply(Array.prototype.splice);
1842
- const stringToLowerCase = unapply(String.prototype.toLowerCase);
1843
- const stringToString = unapply(String.prototype.toString);
1844
- const stringMatch = unapply(String.prototype.match);
1845
- const stringReplace = unapply(String.prototype.replace);
1846
- const stringIndexOf = unapply(String.prototype.indexOf);
1847
- const stringTrim = unapply(String.prototype.trim);
1848
- const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
1849
- const regExpTest = unapply(RegExp.prototype.test);
1850
- const typeErrorCreate = unconstruct(TypeError);
1851
- function unapply(func) {
1852
- return function(thisArg) {
1853
- if (thisArg instanceof RegExp) {
1854
- thisArg.lastIndex = 0;
1855
- }
1856
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
1857
- args[_key3 - 1] = arguments[_key3];
1858
- }
1859
- return apply(func, thisArg, args);
1860
- };
1861
- }
1862
- function unconstruct(Func) {
1863
- return function() {
1864
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
1865
- args[_key4] = arguments[_key4];
1866
- }
1867
- return construct(Func, args);
1868
- };
1869
- }
1870
- function addToSet(set, array) {
1871
- let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
1872
- if (setPrototypeOf) {
1873
- setPrototypeOf(set, null);
1787
+ const {
1788
+ entries,
1789
+ setPrototypeOf,
1790
+ isFrozen,
1791
+ getPrototypeOf,
1792
+ getOwnPropertyDescriptor
1793
+ } = Object;
1794
+ let {
1795
+ freeze,
1796
+ seal,
1797
+ create
1798
+ } = Object;
1799
+ let {
1800
+ apply,
1801
+ construct
1802
+ } = typeof Reflect !== "undefined" && Reflect;
1803
+ if (!freeze) {
1804
+ freeze = function freeze2(x) {
1805
+ return x;
1806
+ };
1807
+ }
1808
+ if (!seal) {
1809
+ seal = function seal2(x) {
1810
+ return x;
1811
+ };
1812
+ }
1813
+ if (!apply) {
1814
+ apply = function apply2(func, thisArg) {
1815
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1816
+ args[_key - 2] = arguments[_key];
1874
1817
  }
1875
- let l = array.length;
1876
- while (l--) {
1877
- let element = array[l];
1878
- if (typeof element === "string") {
1879
- const lcElement = transformCaseFunc(element);
1880
- if (lcElement !== element) {
1881
- if (!isFrozen(array)) {
1882
- array[l] = lcElement;
1883
- }
1884
- element = lcElement;
1818
+ return func.apply(thisArg, args);
1819
+ };
1820
+ }
1821
+ if (!construct) {
1822
+ construct = function construct2(Func) {
1823
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1824
+ args[_key2 - 1] = arguments[_key2];
1825
+ }
1826
+ return new Func(...args);
1827
+ };
1828
+ }
1829
+ const arrayForEach = unapply(Array.prototype.forEach);
1830
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
1831
+ const arrayPop = unapply(Array.prototype.pop);
1832
+ const arrayPush = unapply(Array.prototype.push);
1833
+ const arraySplice = unapply(Array.prototype.splice);
1834
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
1835
+ const stringToString = unapply(String.prototype.toString);
1836
+ const stringMatch = unapply(String.prototype.match);
1837
+ const stringReplace = unapply(String.prototype.replace);
1838
+ const stringIndexOf = unapply(String.prototype.indexOf);
1839
+ const stringTrim = unapply(String.prototype.trim);
1840
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
1841
+ const regExpTest = unapply(RegExp.prototype.test);
1842
+ const typeErrorCreate = unconstruct(TypeError);
1843
+ function unapply(func) {
1844
+ return function(thisArg) {
1845
+ if (thisArg instanceof RegExp) {
1846
+ thisArg.lastIndex = 0;
1847
+ }
1848
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
1849
+ args[_key3 - 1] = arguments[_key3];
1850
+ }
1851
+ return apply(func, thisArg, args);
1852
+ };
1853
+ }
1854
+ function unconstruct(Func) {
1855
+ return function() {
1856
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
1857
+ args[_key4] = arguments[_key4];
1858
+ }
1859
+ return construct(Func, args);
1860
+ };
1861
+ }
1862
+ function addToSet(set, array) {
1863
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
1864
+ if (setPrototypeOf) {
1865
+ setPrototypeOf(set, null);
1866
+ }
1867
+ let l = array.length;
1868
+ while (l--) {
1869
+ let element = array[l];
1870
+ if (typeof element === "string") {
1871
+ const lcElement = transformCaseFunc(element);
1872
+ if (lcElement !== element) {
1873
+ if (!isFrozen(array)) {
1874
+ array[l] = lcElement;
1885
1875
  }
1876
+ element = lcElement;
1886
1877
  }
1887
- set[element] = true;
1888
1878
  }
1889
- return set;
1879
+ set[element] = true;
1880
+ }
1881
+ return set;
1882
+ }
1883
+ function cleanArray(array) {
1884
+ for (let index = 0; index < array.length; index++) {
1885
+ const isPropertyExist = objectHasOwnProperty(array, index);
1886
+ if (!isPropertyExist) {
1887
+ array[index] = null;
1888
+ }
1890
1889
  }
1891
- function cleanArray(array) {
1892
- for (let index = 0; index < array.length; index++) {
1893
- const isPropertyExist = objectHasOwnProperty(array, index);
1894
- if (!isPropertyExist) {
1895
- array[index] = null;
1890
+ return array;
1891
+ }
1892
+ function clone(object) {
1893
+ const newObject = create(null);
1894
+ for (const [property, value] of entries(object)) {
1895
+ const isPropertyExist = objectHasOwnProperty(object, property);
1896
+ if (isPropertyExist) {
1897
+ if (Array.isArray(value)) {
1898
+ newObject[property] = cleanArray(value);
1899
+ } else if (value && typeof value === "object" && value.constructor === Object) {
1900
+ newObject[property] = clone(value);
1901
+ } else {
1902
+ newObject[property] = value;
1896
1903
  }
1897
1904
  }
1898
- return array;
1899
1905
  }
1900
- function clone(object) {
1901
- const newObject = create(null);
1902
- for (const [property, value] of entries(object)) {
1903
- const isPropertyExist = objectHasOwnProperty(object, property);
1904
- if (isPropertyExist) {
1905
- if (Array.isArray(value)) {
1906
- newObject[property] = cleanArray(value);
1907
- } else if (value && typeof value === "object" && value.constructor === Object) {
1908
- newObject[property] = clone(value);
1909
- } else {
1910
- newObject[property] = value;
1911
- }
1906
+ return newObject;
1907
+ }
1908
+ function lookupGetter(object, prop) {
1909
+ while (object !== null) {
1910
+ const desc = getOwnPropertyDescriptor(object, prop);
1911
+ if (desc) {
1912
+ if (desc.get) {
1913
+ return unapply(desc.get);
1914
+ }
1915
+ if (typeof desc.value === "function") {
1916
+ return unapply(desc.value);
1912
1917
  }
1913
1918
  }
1914
- return newObject;
1919
+ object = getPrototypeOf(object);
1915
1920
  }
1916
- function lookupGetter(object, prop) {
1917
- while (object !== null) {
1918
- const desc = getOwnPropertyDescriptor(object, prop);
1919
- if (desc) {
1920
- if (desc.get) {
1921
- return unapply(desc.get);
1922
- }
1923
- if (typeof desc.value === "function") {
1924
- return unapply(desc.value);
1925
- }
1921
+ function fallbackValue() {
1922
+ return null;
1923
+ }
1924
+ return fallbackValue;
1925
+ }
1926
+ const html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
1927
+ const svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
1928
+ const svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
1929
+ const svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
1930
+ const mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
1931
+ const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
1932
+ const text = freeze(["#text"]);
1933
+ const html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]);
1934
+ const svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
1935
+ const mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
1936
+ const xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
1937
+ const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
1938
+ const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
1939
+ const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm);
1940
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
1941
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
1942
+ const IS_ALLOWED_URI = seal(
1943
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
1944
+ // eslint-disable-line no-useless-escape
1945
+ );
1946
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
1947
+ const ATTR_WHITESPACE = seal(
1948
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
1949
+ // eslint-disable-line no-control-regex
1950
+ );
1951
+ const DOCTYPE_NAME = seal(/^html$/i);
1952
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
1953
+ var EXPRESSIONS = /* @__PURE__ */ Object.freeze({
1954
+ __proto__: null,
1955
+ ARIA_ATTR,
1956
+ ATTR_WHITESPACE,
1957
+ CUSTOM_ELEMENT,
1958
+ DATA_ATTR,
1959
+ DOCTYPE_NAME,
1960
+ ERB_EXPR,
1961
+ IS_ALLOWED_URI,
1962
+ IS_SCRIPT_OR_DATA,
1963
+ MUSTACHE_EXPR,
1964
+ TMPLIT_EXPR
1965
+ });
1966
+ const NODE_TYPE = {
1967
+ element: 1,
1968
+ text: 3,
1969
+ // Deprecated
1970
+ progressingInstruction: 7,
1971
+ comment: 8,
1972
+ document: 9
1973
+ };
1974
+ const getGlobal = function getGlobal2() {
1975
+ return typeof window === "undefined" ? null : window;
1976
+ };
1977
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
1978
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
1979
+ return null;
1980
+ }
1981
+ let suffix = null;
1982
+ const ATTR_NAME = "data-tt-policy-suffix";
1983
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
1984
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
1985
+ }
1986
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
1987
+ try {
1988
+ return trustedTypes.createPolicy(policyName, {
1989
+ createHTML(html2) {
1990
+ return html2;
1991
+ },
1992
+ createScriptURL(scriptUrl) {
1993
+ return scriptUrl;
1926
1994
  }
1927
- object = getPrototypeOf(object);
1928
- }
1929
- function fallbackValue() {
1930
- return null;
1931
- }
1932
- return fallbackValue;
1933
- }
1934
- const html$1 = freeze(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]);
1935
- const svg$1 = freeze(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]);
1936
- const svgFilters = freeze(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]);
1937
- const svgDisallowed = freeze(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]);
1938
- const mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]);
1939
- const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
1940
- const text = freeze(["#text"]);
1941
- const html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]);
1942
- const svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
1943
- const mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
1944
- const xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
1945
- const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
1946
- const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
1947
- const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm);
1948
- const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
1949
- const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
1950
- const IS_ALLOWED_URI = seal(
1951
- /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
1952
- // eslint-disable-line no-useless-escape
1953
- );
1954
- const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
1955
- const ATTR_WHITESPACE = seal(
1956
- /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
1957
- // eslint-disable-line no-control-regex
1958
- );
1959
- const DOCTYPE_NAME = seal(/^html$/i);
1960
- const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
1961
- var EXPRESSIONS = /* @__PURE__ */ Object.freeze({
1962
- __proto__: null,
1963
- ARIA_ATTR,
1964
- ATTR_WHITESPACE,
1965
- CUSTOM_ELEMENT,
1966
- DATA_ATTR,
1967
- DOCTYPE_NAME,
1968
- ERB_EXPR,
1969
- IS_ALLOWED_URI,
1970
- IS_SCRIPT_OR_DATA,
1971
- MUSTACHE_EXPR,
1972
- TMPLIT_EXPR
1973
- });
1974
- const NODE_TYPE = {
1975
- element: 1,
1976
- text: 3,
1977
- // Deprecated
1978
- progressingInstruction: 7,
1979
- comment: 8,
1980
- document: 9
1995
+ });
1996
+ } catch (_) {
1997
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
1998
+ return null;
1999
+ }
2000
+ };
2001
+ const _createHooksMap = function _createHooksMap2() {
2002
+ return {
2003
+ afterSanitizeAttributes: [],
2004
+ afterSanitizeElements: [],
2005
+ afterSanitizeShadowDOM: [],
2006
+ beforeSanitizeAttributes: [],
2007
+ beforeSanitizeElements: [],
2008
+ beforeSanitizeShadowDOM: [],
2009
+ uponSanitizeAttribute: [],
2010
+ uponSanitizeElement: [],
2011
+ uponSanitizeShadowNode: []
1981
2012
  };
1982
- const getGlobal = function getGlobal2() {
1983
- return typeof window === "undefined" ? null : window;
2013
+ };
2014
+ function createDOMPurify() {
2015
+ let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
2016
+ const DOMPurify = (root) => createDOMPurify(root);
2017
+ DOMPurify.version = "3.3.1";
2018
+ DOMPurify.removed = [];
2019
+ if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
2020
+ DOMPurify.isSupported = false;
2021
+ return DOMPurify;
2022
+ }
2023
+ let {
2024
+ document
2025
+ } = window2;
2026
+ const originalDocument = document;
2027
+ const currentScript = originalDocument.currentScript;
2028
+ const {
2029
+ DocumentFragment,
2030
+ HTMLTemplateElement,
2031
+ Node,
2032
+ Element,
2033
+ NodeFilter,
2034
+ NamedNodeMap = window2.NamedNodeMap || window2.MozNamedAttrMap,
2035
+ HTMLFormElement,
2036
+ DOMParser,
2037
+ trustedTypes
2038
+ } = window2;
2039
+ const ElementPrototype = Element.prototype;
2040
+ const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
2041
+ const remove = lookupGetter(ElementPrototype, "remove");
2042
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
2043
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
2044
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
2045
+ if (typeof HTMLTemplateElement === "function") {
2046
+ const template = document.createElement("template");
2047
+ if (template.content && template.content.ownerDocument) {
2048
+ document = template.content.ownerDocument;
2049
+ }
2050
+ }
2051
+ let trustedTypesPolicy;
2052
+ let emptyHTML = "";
2053
+ const {
2054
+ implementation,
2055
+ createNodeIterator,
2056
+ createDocumentFragment,
2057
+ getElementsByTagName
2058
+ } = document;
2059
+ const {
2060
+ importNode
2061
+ } = originalDocument;
2062
+ let hooks = _createHooksMap();
2063
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
2064
+ const {
2065
+ MUSTACHE_EXPR: MUSTACHE_EXPR2,
2066
+ ERB_EXPR: ERB_EXPR2,
2067
+ TMPLIT_EXPR: TMPLIT_EXPR2,
2068
+ DATA_ATTR: DATA_ATTR2,
2069
+ ARIA_ATTR: ARIA_ATTR2,
2070
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA2,
2071
+ ATTR_WHITESPACE: ATTR_WHITESPACE2,
2072
+ CUSTOM_ELEMENT: CUSTOM_ELEMENT2
2073
+ } = EXPRESSIONS;
2074
+ let {
2075
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
2076
+ } = EXPRESSIONS;
2077
+ let ALLOWED_TAGS = null;
2078
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
2079
+ let ALLOWED_ATTR = null;
2080
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
2081
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
2082
+ tagNameCheck: {
2083
+ writable: true,
2084
+ configurable: false,
2085
+ enumerable: true,
2086
+ value: null
2087
+ },
2088
+ attributeNameCheck: {
2089
+ writable: true,
2090
+ configurable: false,
2091
+ enumerable: true,
2092
+ value: null
2093
+ },
2094
+ allowCustomizedBuiltInElements: {
2095
+ writable: true,
2096
+ configurable: false,
2097
+ enumerable: true,
2098
+ value: false
2099
+ }
2100
+ }));
2101
+ let FORBID_TAGS = null;
2102
+ let FORBID_ATTR = null;
2103
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
2104
+ tagCheck: {
2105
+ writable: true,
2106
+ configurable: false,
2107
+ enumerable: true,
2108
+ value: null
2109
+ },
2110
+ attributeCheck: {
2111
+ writable: true,
2112
+ configurable: false,
2113
+ enumerable: true,
2114
+ value: null
2115
+ }
2116
+ }));
2117
+ let ALLOW_ARIA_ATTR = true;
2118
+ let ALLOW_DATA_ATTR = true;
2119
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
2120
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
2121
+ let SAFE_FOR_TEMPLATES = false;
2122
+ let SAFE_FOR_XML = true;
2123
+ let WHOLE_DOCUMENT = false;
2124
+ let SET_CONFIG = false;
2125
+ let FORCE_BODY = false;
2126
+ let RETURN_DOM = false;
2127
+ let RETURN_DOM_FRAGMENT = false;
2128
+ let RETURN_TRUSTED_TYPE = false;
2129
+ let SANITIZE_DOM = true;
2130
+ let SANITIZE_NAMED_PROPS = false;
2131
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
2132
+ let KEEP_CONTENT = true;
2133
+ let IN_PLACE = false;
2134
+ let USE_PROFILES = {};
2135
+ let FORBID_CONTENTS = null;
2136
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
2137
+ let DATA_URI_TAGS = null;
2138
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
2139
+ let URI_SAFE_ATTRIBUTES = null;
2140
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
2141
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
2142
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
2143
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
2144
+ let NAMESPACE = HTML_NAMESPACE;
2145
+ let IS_EMPTY_INPUT = false;
2146
+ let ALLOWED_NAMESPACES = null;
2147
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
2148
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
2149
+ let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
2150
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
2151
+ let PARSER_MEDIA_TYPE = null;
2152
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
2153
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
2154
+ let transformCaseFunc = null;
2155
+ let CONFIG = null;
2156
+ const formElement = document.createElement("form");
2157
+ const isRegexOrFunction = function isRegexOrFunction2(testValue) {
2158
+ return testValue instanceof RegExp || testValue instanceof Function;
1984
2159
  };
1985
- const _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
1986
- if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
1987
- return null;
1988
- }
1989
- let suffix = null;
1990
- const ATTR_NAME = "data-tt-policy-suffix";
1991
- if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
1992
- suffix = purifyHostElement.getAttribute(ATTR_NAME);
1993
- }
1994
- const policyName = "dompurify" + (suffix ? "#" + suffix : "");
1995
- try {
1996
- return trustedTypes.createPolicy(policyName, {
1997
- createHTML(html2) {
1998
- return html2;
1999
- },
2000
- createScriptURL(scriptUrl) {
2001
- return scriptUrl;
2002
- }
2003
- });
2004
- } catch (_) {
2005
- console.warn("TrustedTypes policy " + policyName + " could not be created.");
2006
- return null;
2160
+ const _parseConfig = function _parseConfig2() {
2161
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2162
+ if (CONFIG && CONFIG === cfg) {
2163
+ return;
2007
2164
  }
2008
- };
2009
- const _createHooksMap = function _createHooksMap2() {
2010
- return {
2011
- afterSanitizeAttributes: [],
2012
- afterSanitizeElements: [],
2013
- afterSanitizeShadowDOM: [],
2014
- beforeSanitizeAttributes: [],
2015
- beforeSanitizeElements: [],
2016
- beforeSanitizeShadowDOM: [],
2017
- uponSanitizeAttribute: [],
2018
- uponSanitizeElement: [],
2019
- uponSanitizeShadowNode: []
2020
- };
2021
- };
2022
- function createDOMPurify() {
2023
- let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
2024
- const DOMPurify2 = (root) => createDOMPurify(root);
2025
- DOMPurify2.version = "3.3.1";
2026
- DOMPurify2.removed = [];
2027
- if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
2028
- DOMPurify2.isSupported = false;
2029
- return DOMPurify2;
2030
- }
2031
- let {
2032
- document
2033
- } = window2;
2034
- const originalDocument = document;
2035
- const currentScript = originalDocument.currentScript;
2036
- const {
2037
- DocumentFragment,
2038
- HTMLTemplateElement,
2039
- Node,
2040
- Element,
2041
- NodeFilter,
2042
- NamedNodeMap = window2.NamedNodeMap || window2.MozNamedAttrMap,
2043
- HTMLFormElement,
2044
- DOMParser,
2045
- trustedTypes
2046
- } = window2;
2047
- const ElementPrototype = Element.prototype;
2048
- const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
2049
- const remove = lookupGetter(ElementPrototype, "remove");
2050
- const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
2051
- const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
2052
- const getParentNode = lookupGetter(ElementPrototype, "parentNode");
2053
- if (typeof HTMLTemplateElement === "function") {
2054
- const template = document.createElement("template");
2055
- if (template.content && template.content.ownerDocument) {
2056
- document = template.content.ownerDocument;
2057
- }
2058
- }
2059
- let trustedTypesPolicy;
2060
- let emptyHTML = "";
2061
- const {
2062
- implementation,
2063
- createNodeIterator,
2064
- createDocumentFragment,
2065
- getElementsByTagName
2066
- } = document;
2067
- const {
2068
- importNode
2069
- } = originalDocument;
2070
- let hooks = _createHooksMap();
2071
- DOMPurify2.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
2072
- const {
2073
- MUSTACHE_EXPR: MUSTACHE_EXPR2,
2074
- ERB_EXPR: ERB_EXPR2,
2075
- TMPLIT_EXPR: TMPLIT_EXPR2,
2076
- DATA_ATTR: DATA_ATTR2,
2077
- ARIA_ATTR: ARIA_ATTR2,
2078
- IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA2,
2079
- ATTR_WHITESPACE: ATTR_WHITESPACE2,
2080
- CUSTOM_ELEMENT: CUSTOM_ELEMENT2
2081
- } = EXPRESSIONS;
2082
- let {
2083
- IS_ALLOWED_URI: IS_ALLOWED_URI$1
2084
- } = EXPRESSIONS;
2085
- let ALLOWED_TAGS = null;
2086
- const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
2087
- let ALLOWED_ATTR = null;
2088
- const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
2089
- let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
2090
- tagNameCheck: {
2091
- writable: true,
2092
- configurable: false,
2093
- enumerable: true,
2094
- value: null
2095
- },
2096
- attributeNameCheck: {
2097
- writable: true,
2098
- configurable: false,
2099
- enumerable: true,
2100
- value: null
2101
- },
2102
- allowCustomizedBuiltInElements: {
2103
- writable: true,
2104
- configurable: false,
2105
- enumerable: true,
2106
- value: false
2107
- }
2108
- }));
2109
- let FORBID_TAGS = null;
2110
- let FORBID_ATTR = null;
2111
- const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
2112
- tagCheck: {
2113
- writable: true,
2114
- configurable: false,
2115
- enumerable: true,
2116
- value: null
2117
- },
2118
- attributeCheck: {
2119
- writable: true,
2120
- configurable: false,
2121
- enumerable: true,
2122
- value: null
2123
- }
2124
- }));
2125
- let ALLOW_ARIA_ATTR = true;
2126
- let ALLOW_DATA_ATTR = true;
2127
- let ALLOW_UNKNOWN_PROTOCOLS = false;
2128
- let ALLOW_SELF_CLOSE_IN_ATTR = true;
2129
- let SAFE_FOR_TEMPLATES = false;
2130
- let SAFE_FOR_XML = true;
2131
- let WHOLE_DOCUMENT = false;
2132
- let SET_CONFIG = false;
2133
- let FORCE_BODY = false;
2134
- let RETURN_DOM = false;
2135
- let RETURN_DOM_FRAGMENT = false;
2136
- let RETURN_TRUSTED_TYPE = false;
2137
- let SANITIZE_DOM = true;
2138
- let SANITIZE_NAMED_PROPS = false;
2139
- const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
2140
- let KEEP_CONTENT = true;
2141
- let IN_PLACE = false;
2142
- let USE_PROFILES = {};
2143
- let FORBID_CONTENTS = null;
2144
- const DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
2145
- let DATA_URI_TAGS = null;
2146
- const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
2147
- let URI_SAFE_ATTRIBUTES = null;
2148
- const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
2149
- const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
2150
- const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
2151
- const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
2152
- let NAMESPACE = HTML_NAMESPACE;
2153
- let IS_EMPTY_INPUT = false;
2154
- let ALLOWED_NAMESPACES = null;
2155
- const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
2156
- let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
2157
- let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
2158
- const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
2159
- let PARSER_MEDIA_TYPE = null;
2160
- const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
2161
- const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
2162
- let transformCaseFunc = null;
2163
- let CONFIG = null;
2164
- const formElement = document.createElement("form");
2165
- const isRegexOrFunction = function isRegexOrFunction2(testValue) {
2166
- return testValue instanceof RegExp || testValue instanceof Function;
2167
- };
2168
- const _parseConfig = function _parseConfig2() {
2169
- let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2170
- if (CONFIG && CONFIG === cfg) {
2171
- return;
2172
- }
2173
- if (!cfg || typeof cfg !== "object") {
2174
- cfg = {};
2175
- }
2176
- cfg = clone(cfg);
2177
- PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
2178
- SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
2179
- transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
2180
- ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
2181
- ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
2182
- ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
2183
- URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
2184
- DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
2185
- FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
2186
- FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
2187
- FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
2188
- USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES : false;
2189
- ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
2190
- ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
2191
- ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
2192
- ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
2193
- SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
2194
- SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
2195
- WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
2196
- RETURN_DOM = cfg.RETURN_DOM || false;
2197
- RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
2198
- RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
2199
- FORCE_BODY = cfg.FORCE_BODY || false;
2200
- SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
2201
- SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
2202
- KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
2203
- IN_PLACE = cfg.IN_PLACE || false;
2204
- IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
2205
- NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
2206
- MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
2207
- HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
2208
- CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
2209
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
2210
- CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
2211
- }
2212
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
2213
- CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
2214
- }
2215
- if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") {
2216
- CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
2217
- }
2218
- if (SAFE_FOR_TEMPLATES) {
2219
- ALLOW_DATA_ATTR = false;
2220
- }
2221
- if (RETURN_DOM_FRAGMENT) {
2222
- RETURN_DOM = true;
2223
- }
2224
- if (USE_PROFILES) {
2225
- ALLOWED_TAGS = addToSet({}, text);
2226
- ALLOWED_ATTR = [];
2227
- if (USE_PROFILES.html === true) {
2228
- addToSet(ALLOWED_TAGS, html$1);
2229
- addToSet(ALLOWED_ATTR, html);
2230
- }
2231
- if (USE_PROFILES.svg === true) {
2232
- addToSet(ALLOWED_TAGS, svg$1);
2233
- addToSet(ALLOWED_ATTR, svg);
2234
- addToSet(ALLOWED_ATTR, xml);
2235
- }
2236
- if (USE_PROFILES.svgFilters === true) {
2237
- addToSet(ALLOWED_TAGS, svgFilters);
2238
- addToSet(ALLOWED_ATTR, svg);
2239
- addToSet(ALLOWED_ATTR, xml);
2240
- }
2241
- if (USE_PROFILES.mathMl === true) {
2242
- addToSet(ALLOWED_TAGS, mathMl$1);
2243
- addToSet(ALLOWED_ATTR, mathMl);
2244
- addToSet(ALLOWED_ATTR, xml);
2165
+ if (!cfg || typeof cfg !== "object") {
2166
+ cfg = {};
2167
+ }
2168
+ cfg = clone(cfg);
2169
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
2170
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
2171
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
2172
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
2173
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
2174
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
2175
+ URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
2176
+ DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
2177
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
2178
+ FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
2179
+ FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
2180
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES : false;
2181
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
2182
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
2183
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
2184
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
2185
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
2186
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
2187
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
2188
+ RETURN_DOM = cfg.RETURN_DOM || false;
2189
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
2190
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
2191
+ FORCE_BODY = cfg.FORCE_BODY || false;
2192
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
2193
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
2194
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
2195
+ IN_PLACE = cfg.IN_PLACE || false;
2196
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
2197
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
2198
+ MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
2199
+ HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
2200
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
2201
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
2202
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
2203
+ }
2204
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
2205
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
2206
+ }
2207
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") {
2208
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
2209
+ }
2210
+ if (SAFE_FOR_TEMPLATES) {
2211
+ ALLOW_DATA_ATTR = false;
2212
+ }
2213
+ if (RETURN_DOM_FRAGMENT) {
2214
+ RETURN_DOM = true;
2215
+ }
2216
+ if (USE_PROFILES) {
2217
+ ALLOWED_TAGS = addToSet({}, text);
2218
+ ALLOWED_ATTR = [];
2219
+ if (USE_PROFILES.html === true) {
2220
+ addToSet(ALLOWED_TAGS, html$1);
2221
+ addToSet(ALLOWED_ATTR, html);
2222
+ }
2223
+ if (USE_PROFILES.svg === true) {
2224
+ addToSet(ALLOWED_TAGS, svg$1);
2225
+ addToSet(ALLOWED_ATTR, svg);
2226
+ addToSet(ALLOWED_ATTR, xml);
2227
+ }
2228
+ if (USE_PROFILES.svgFilters === true) {
2229
+ addToSet(ALLOWED_TAGS, svgFilters);
2230
+ addToSet(ALLOWED_ATTR, svg);
2231
+ addToSet(ALLOWED_ATTR, xml);
2232
+ }
2233
+ if (USE_PROFILES.mathMl === true) {
2234
+ addToSet(ALLOWED_TAGS, mathMl$1);
2235
+ addToSet(ALLOWED_ATTR, mathMl);
2236
+ addToSet(ALLOWED_ATTR, xml);
2237
+ }
2238
+ }
2239
+ if (cfg.ADD_TAGS) {
2240
+ if (typeof cfg.ADD_TAGS === "function") {
2241
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
2242
+ } else {
2243
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
2244
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
2245
2245
  }
2246
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
2246
2247
  }
2247
- if (cfg.ADD_TAGS) {
2248
- if (typeof cfg.ADD_TAGS === "function") {
2249
- EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
2250
- } else {
2251
- if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
2252
- ALLOWED_TAGS = clone(ALLOWED_TAGS);
2253
- }
2254
- addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
2248
+ }
2249
+ if (cfg.ADD_ATTR) {
2250
+ if (typeof cfg.ADD_ATTR === "function") {
2251
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
2252
+ } else {
2253
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
2254
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
2255
2255
  }
2256
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
2256
2257
  }
2257
- if (cfg.ADD_ATTR) {
2258
- if (typeof cfg.ADD_ATTR === "function") {
2259
- EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
2260
- } else {
2261
- if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
2262
- ALLOWED_ATTR = clone(ALLOWED_ATTR);
2263
- }
2264
- addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
2265
- }
2258
+ }
2259
+ if (cfg.ADD_URI_SAFE_ATTR) {
2260
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
2261
+ }
2262
+ if (cfg.FORBID_CONTENTS) {
2263
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
2264
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
2266
2265
  }
2267
- if (cfg.ADD_URI_SAFE_ATTR) {
2268
- addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
2266
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
2267
+ }
2268
+ if (cfg.ADD_FORBID_CONTENTS) {
2269
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
2270
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
2269
2271
  }
2270
- if (cfg.FORBID_CONTENTS) {
2271
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
2272
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
2273
- }
2274
- addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
2272
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
2273
+ }
2274
+ if (KEEP_CONTENT) {
2275
+ ALLOWED_TAGS["#text"] = true;
2276
+ }
2277
+ if (WHOLE_DOCUMENT) {
2278
+ addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
2279
+ }
2280
+ if (ALLOWED_TAGS.table) {
2281
+ addToSet(ALLOWED_TAGS, ["tbody"]);
2282
+ delete FORBID_TAGS.tbody;
2283
+ }
2284
+ if (cfg.TRUSTED_TYPES_POLICY) {
2285
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
2286
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
2275
2287
  }
2276
- if (cfg.ADD_FORBID_CONTENTS) {
2277
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
2278
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
2279
- }
2280
- addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
2288
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
2289
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
2281
2290
  }
2282
- if (KEEP_CONTENT) {
2283
- ALLOWED_TAGS["#text"] = true;
2291
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
2292
+ emptyHTML = trustedTypesPolicy.createHTML("");
2293
+ } else {
2294
+ if (trustedTypesPolicy === void 0) {
2295
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
2284
2296
  }
2285
- if (WHOLE_DOCUMENT) {
2286
- addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
2297
+ if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
2298
+ emptyHTML = trustedTypesPolicy.createHTML("");
2287
2299
  }
2288
- if (ALLOWED_TAGS.table) {
2289
- addToSet(ALLOWED_TAGS, ["tbody"]);
2290
- delete FORBID_TAGS.tbody;
2300
+ }
2301
+ if (freeze) {
2302
+ freeze(cfg);
2303
+ }
2304
+ CONFIG = cfg;
2305
+ };
2306
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
2307
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
2308
+ const _checkValidNamespace = function _checkValidNamespace2(element) {
2309
+ let parent = getParentNode(element);
2310
+ if (!parent || !parent.tagName) {
2311
+ parent = {
2312
+ namespaceURI: NAMESPACE,
2313
+ tagName: "template"
2314
+ };
2315
+ }
2316
+ const tagName = stringToLowerCase(element.tagName);
2317
+ const parentTagName = stringToLowerCase(parent.tagName);
2318
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
2319
+ return false;
2320
+ }
2321
+ if (element.namespaceURI === SVG_NAMESPACE) {
2322
+ if (parent.namespaceURI === HTML_NAMESPACE) {
2323
+ return tagName === "svg";
2291
2324
  }
2292
- if (cfg.TRUSTED_TYPES_POLICY) {
2293
- if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
2294
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
2295
- }
2296
- if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
2297
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
2298
- }
2299
- trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
2300
- emptyHTML = trustedTypesPolicy.createHTML("");
2301
- } else {
2302
- if (trustedTypesPolicy === void 0) {
2303
- trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
2304
- }
2305
- if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
2306
- emptyHTML = trustedTypesPolicy.createHTML("");
2307
- }
2325
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
2326
+ return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
2308
2327
  }
2309
- if (freeze) {
2310
- freeze(cfg);
2328
+ return Boolean(ALL_SVG_TAGS[tagName]);
2329
+ }
2330
+ if (element.namespaceURI === MATHML_NAMESPACE) {
2331
+ if (parent.namespaceURI === HTML_NAMESPACE) {
2332
+ return tagName === "math";
2311
2333
  }
2312
- CONFIG = cfg;
2313
- };
2314
- const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
2315
- const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
2316
- const _checkValidNamespace = function _checkValidNamespace2(element) {
2317
- let parent = getParentNode(element);
2318
- if (!parent || !parent.tagName) {
2319
- parent = {
2320
- namespaceURI: NAMESPACE,
2321
- tagName: "template"
2322
- };
2334
+ if (parent.namespaceURI === SVG_NAMESPACE) {
2335
+ return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
2323
2336
  }
2324
- const tagName = stringToLowerCase(element.tagName);
2325
- const parentTagName = stringToLowerCase(parent.tagName);
2326
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
2337
+ return Boolean(ALL_MATHML_TAGS[tagName]);
2338
+ }
2339
+ if (element.namespaceURI === HTML_NAMESPACE) {
2340
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
2327
2341
  return false;
2328
2342
  }
2329
- if (element.namespaceURI === SVG_NAMESPACE) {
2330
- if (parent.namespaceURI === HTML_NAMESPACE) {
2331
- return tagName === "svg";
2332
- }
2333
- if (parent.namespaceURI === MATHML_NAMESPACE) {
2334
- return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
2335
- }
2336
- return Boolean(ALL_SVG_TAGS[tagName]);
2337
- }
2338
- if (element.namespaceURI === MATHML_NAMESPACE) {
2339
- if (parent.namespaceURI === HTML_NAMESPACE) {
2340
- return tagName === "math";
2341
- }
2342
- if (parent.namespaceURI === SVG_NAMESPACE) {
2343
- return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
2344
- }
2345
- return Boolean(ALL_MATHML_TAGS[tagName]);
2343
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
2344
+ return false;
2346
2345
  }
2347
- if (element.namespaceURI === HTML_NAMESPACE) {
2348
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
2349
- return false;
2346
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
2347
+ }
2348
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
2349
+ return true;
2350
+ }
2351
+ return false;
2352
+ };
2353
+ const _forceRemove = function _forceRemove2(node) {
2354
+ arrayPush(DOMPurify.removed, {
2355
+ element: node
2356
+ });
2357
+ try {
2358
+ getParentNode(node).removeChild(node);
2359
+ } catch (_) {
2360
+ remove(node);
2361
+ }
2362
+ };
2363
+ const _removeAttribute = function _removeAttribute2(name, element) {
2364
+ try {
2365
+ arrayPush(DOMPurify.removed, {
2366
+ attribute: element.getAttributeNode(name),
2367
+ from: element
2368
+ });
2369
+ } catch (_) {
2370
+ arrayPush(DOMPurify.removed, {
2371
+ attribute: null,
2372
+ from: element
2373
+ });
2374
+ }
2375
+ element.removeAttribute(name);
2376
+ if (name === "is") {
2377
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
2378
+ try {
2379
+ _forceRemove(element);
2380
+ } catch (_) {
2350
2381
  }
2351
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
2352
- return false;
2382
+ } else {
2383
+ try {
2384
+ element.setAttribute(name, "");
2385
+ } catch (_) {
2353
2386
  }
2354
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
2355
2387
  }
2356
- if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
2357
- return true;
2358
- }
2359
- return false;
2360
- };
2361
- const _forceRemove = function _forceRemove2(node) {
2362
- arrayPush(DOMPurify2.removed, {
2363
- element: node
2364
- });
2388
+ }
2389
+ };
2390
+ const _initDocument = function _initDocument2(dirty) {
2391
+ let doc = null;
2392
+ let leadingWhitespace = null;
2393
+ if (FORCE_BODY) {
2394
+ dirty = "<remove></remove>" + dirty;
2395
+ } else {
2396
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
2397
+ leadingWhitespace = matches && matches[0];
2398
+ }
2399
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
2400
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
2401
+ }
2402
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
2403
+ if (NAMESPACE === HTML_NAMESPACE) {
2365
2404
  try {
2366
- getParentNode(node).removeChild(node);
2405
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
2367
2406
  } catch (_) {
2368
- remove(node);
2369
2407
  }
2370
- };
2371
- const _removeAttribute = function _removeAttribute2(name, element) {
2408
+ }
2409
+ if (!doc || !doc.documentElement) {
2410
+ doc = implementation.createDocument(NAMESPACE, "template", null);
2372
2411
  try {
2373
- arrayPush(DOMPurify2.removed, {
2374
- attribute: element.getAttributeNode(name),
2375
- from: element
2376
- });
2412
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
2377
2413
  } catch (_) {
2378
- arrayPush(DOMPurify2.removed, {
2379
- attribute: null,
2380
- from: element
2381
- });
2382
2414
  }
2383
- element.removeAttribute(name);
2384
- if (name === "is") {
2385
- if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
2386
- try {
2387
- _forceRemove(element);
2388
- } catch (_) {
2389
- }
2390
- } else {
2391
- try {
2392
- element.setAttribute(name, "");
2393
- } catch (_) {
2394
- }
2415
+ }
2416
+ const body = doc.body || doc.documentElement;
2417
+ if (dirty && leadingWhitespace) {
2418
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
2419
+ }
2420
+ if (NAMESPACE === HTML_NAMESPACE) {
2421
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
2422
+ }
2423
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
2424
+ };
2425
+ const _createNodeIterator = function _createNodeIterator2(root) {
2426
+ return createNodeIterator.call(
2427
+ root.ownerDocument || root,
2428
+ root,
2429
+ // eslint-disable-next-line no-bitwise
2430
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
2431
+ null
2432
+ );
2433
+ };
2434
+ const _isClobbered = function _isClobbered2(element) {
2435
+ return element instanceof HTMLFormElement && (typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function");
2436
+ };
2437
+ const _isNode = function _isNode2(value) {
2438
+ return typeof Node === "function" && value instanceof Node;
2439
+ };
2440
+ function _executeHooks(hooks2, currentNode, data) {
2441
+ arrayForEach(hooks2, (hook) => {
2442
+ hook.call(DOMPurify, currentNode, data, CONFIG);
2443
+ });
2444
+ }
2445
+ const _sanitizeElements = function _sanitizeElements2(currentNode) {
2446
+ let content = null;
2447
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
2448
+ if (_isClobbered(currentNode)) {
2449
+ _forceRemove(currentNode);
2450
+ return true;
2451
+ }
2452
+ const tagName = transformCaseFunc(currentNode.nodeName);
2453
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
2454
+ tagName,
2455
+ allowedTags: ALLOWED_TAGS
2456
+ });
2457
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
2458
+ _forceRemove(currentNode);
2459
+ return true;
2460
+ }
2461
+ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
2462
+ _forceRemove(currentNode);
2463
+ return true;
2464
+ }
2465
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
2466
+ _forceRemove(currentNode);
2467
+ return true;
2468
+ }
2469
+ if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) {
2470
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
2471
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
2472
+ return false;
2395
2473
  }
2396
- }
2397
- };
2398
- const _initDocument = function _initDocument2(dirty) {
2399
- let doc = null;
2400
- let leadingWhitespace = null;
2401
- if (FORCE_BODY) {
2402
- dirty = "<remove></remove>" + dirty;
2403
- } else {
2404
- const matches = stringMatch(dirty, /^[\r\n\t ]+/);
2405
- leadingWhitespace = matches && matches[0];
2406
- }
2407
- if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
2408
- dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
2409
- }
2410
- const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
2411
- if (NAMESPACE === HTML_NAMESPACE) {
2412
- try {
2413
- doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
2414
- } catch (_) {
2474
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
2475
+ return false;
2415
2476
  }
2416
2477
  }
2417
- if (!doc || !doc.documentElement) {
2418
- doc = implementation.createDocument(NAMESPACE, "template", null);
2419
- try {
2420
- doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
2421
- } catch (_) {
2478
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
2479
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
2480
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
2481
+ if (childNodes && parentNode) {
2482
+ const childCount = childNodes.length;
2483
+ for (let i = childCount - 1; i >= 0; --i) {
2484
+ const childClone = cloneNode(childNodes[i], true);
2485
+ childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
2486
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
2487
+ }
2422
2488
  }
2423
2489
  }
2424
- const body = doc.body || doc.documentElement;
2425
- if (dirty && leadingWhitespace) {
2426
- body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
2427
- }
2428
- if (NAMESPACE === HTML_NAMESPACE) {
2429
- return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
2430
- }
2431
- return WHOLE_DOCUMENT ? doc.documentElement : body;
2432
- };
2433
- const _createNodeIterator = function _createNodeIterator2(root) {
2434
- return createNodeIterator.call(
2435
- root.ownerDocument || root,
2436
- root,
2437
- // eslint-disable-next-line no-bitwise
2438
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
2439
- null
2440
- );
2441
- };
2442
- const _isClobbered = function _isClobbered2(element) {
2443
- return element instanceof HTMLFormElement && (typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function");
2444
- };
2445
- const _isNode = function _isNode2(value) {
2446
- return typeof Node === "function" && value instanceof Node;
2447
- };
2448
- function _executeHooks(hooks2, currentNode, data) {
2449
- arrayForEach(hooks2, (hook) => {
2450
- hook.call(DOMPurify2, currentNode, data, CONFIG);
2451
- });
2490
+ _forceRemove(currentNode);
2491
+ return true;
2452
2492
  }
2453
- const _sanitizeElements = function _sanitizeElements2(currentNode) {
2454
- let content = null;
2455
- _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
2456
- if (_isClobbered(currentNode)) {
2457
- _forceRemove(currentNode);
2458
- return true;
2459
- }
2460
- const tagName = transformCaseFunc(currentNode.nodeName);
2461
- _executeHooks(hooks.uponSanitizeElement, currentNode, {
2462
- tagName,
2463
- allowedTags: ALLOWED_TAGS
2493
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
2494
+ _forceRemove(currentNode);
2495
+ return true;
2496
+ }
2497
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
2498
+ _forceRemove(currentNode);
2499
+ return true;
2500
+ }
2501
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
2502
+ content = currentNode.textContent;
2503
+ arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
2504
+ content = stringReplace(content, expr, " ");
2464
2505
  });
2465
- if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
2466
- _forceRemove(currentNode);
2467
- return true;
2468
- }
2469
- if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
2470
- _forceRemove(currentNode);
2471
- return true;
2472
- }
2473
- if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
2474
- _forceRemove(currentNode);
2475
- return true;
2476
- }
2477
- if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) {
2478
- if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
2479
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
2480
- return false;
2481
- }
2482
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
2483
- return false;
2484
- }
2485
- }
2486
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
2487
- const parentNode = getParentNode(currentNode) || currentNode.parentNode;
2488
- const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
2489
- if (childNodes && parentNode) {
2490
- const childCount = childNodes.length;
2491
- for (let i = childCount - 1; i >= 0; --i) {
2492
- const childClone = cloneNode(childNodes[i], true);
2493
- childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
2494
- parentNode.insertBefore(childClone, getNextSibling(currentNode));
2495
- }
2496
- }
2497
- }
2498
- _forceRemove(currentNode);
2499
- return true;
2506
+ if (currentNode.textContent !== content) {
2507
+ arrayPush(DOMPurify.removed, {
2508
+ element: currentNode.cloneNode()
2509
+ });
2510
+ currentNode.textContent = content;
2500
2511
  }
2501
- if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
2502
- _forceRemove(currentNode);
2503
- return true;
2512
+ }
2513
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2514
+ return false;
2515
+ };
2516
+ const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
2517
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document || value in formElement)) {
2518
+ return false;
2519
+ }
2520
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR2, lcName)) ;
2521
+ else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR2, lcName)) ;
2522
+ else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ;
2523
+ else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
2524
+ if (
2525
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
2526
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2527
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
2528
+ _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND
2529
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2530
+ lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))
2531
+ ) ;
2532
+ else {
2533
+ return false;
2504
2534
  }
2505
- if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
2506
- _forceRemove(currentNode);
2507
- return true;
2535
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
2536
+ else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
2537
+ else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
2538
+ else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA2, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
2539
+ else if (value) {
2540
+ return false;
2541
+ } else ;
2542
+ return true;
2543
+ };
2544
+ const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
2545
+ return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT2);
2546
+ };
2547
+ const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
2548
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
2549
+ const {
2550
+ attributes
2551
+ } = currentNode;
2552
+ if (!attributes || _isClobbered(currentNode)) {
2553
+ return;
2554
+ }
2555
+ const hookEvent = {
2556
+ attrName: "",
2557
+ attrValue: "",
2558
+ keepAttr: true,
2559
+ allowedAttributes: ALLOWED_ATTR,
2560
+ forceKeepAttr: void 0
2561
+ };
2562
+ let l = attributes.length;
2563
+ while (l--) {
2564
+ const attr = attributes[l];
2565
+ const {
2566
+ name,
2567
+ namespaceURI,
2568
+ value: attrValue
2569
+ } = attr;
2570
+ const lcName = transformCaseFunc(name);
2571
+ const initValue = attrValue;
2572
+ let value = name === "value" ? initValue : stringTrim(initValue);
2573
+ hookEvent.attrName = lcName;
2574
+ hookEvent.attrValue = value;
2575
+ hookEvent.keepAttr = true;
2576
+ hookEvent.forceKeepAttr = void 0;
2577
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
2578
+ value = hookEvent.attrValue;
2579
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name")) {
2580
+ _removeAttribute(name, currentNode);
2581
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
2582
+ }
2583
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, value)) {
2584
+ _removeAttribute(name, currentNode);
2585
+ continue;
2586
+ }
2587
+ if (lcName === "attributename" && stringMatch(value, "href")) {
2588
+ _removeAttribute(name, currentNode);
2589
+ continue;
2590
+ }
2591
+ if (hookEvent.forceKeepAttr) {
2592
+ continue;
2593
+ }
2594
+ if (!hookEvent.keepAttr) {
2595
+ _removeAttribute(name, currentNode);
2596
+ continue;
2597
+ }
2598
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
2599
+ _removeAttribute(name, currentNode);
2600
+ continue;
2508
2601
  }
2509
- if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
2510
- content = currentNode.textContent;
2602
+ if (SAFE_FOR_TEMPLATES) {
2511
2603
  arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
2512
- content = stringReplace(content, expr, " ");
2604
+ value = stringReplace(value, expr, " ");
2513
2605
  });
2514
- if (currentNode.textContent !== content) {
2515
- arrayPush(DOMPurify2.removed, {
2516
- element: currentNode.cloneNode()
2517
- });
2518
- currentNode.textContent = content;
2519
- }
2520
2606
  }
2521
- _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2522
- return false;
2523
- };
2524
- const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
2525
- if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document || value in formElement)) {
2526
- return false;
2607
+ const lcTag = transformCaseFunc(currentNode.nodeName);
2608
+ if (!_isValidAttribute(lcTag, lcName, value)) {
2609
+ _removeAttribute(name, currentNode);
2610
+ continue;
2527
2611
  }
2528
- if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR2, lcName)) ;
2529
- else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR2, lcName)) ;
2530
- else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ;
2531
- else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
2532
- if (
2533
- // First condition does a very basic check if a) it's basically a valid custom element tagname AND
2534
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2535
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
2536
- _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND
2537
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2538
- lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))
2539
- ) ;
2612
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
2613
+ if (namespaceURI) ;
2540
2614
  else {
2541
- return false;
2542
- }
2543
- } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
2544
- else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
2545
- else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
2546
- else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA2, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
2547
- else if (value) {
2548
- return false;
2549
- } else ;
2550
- return true;
2551
- };
2552
- const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
2553
- return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT2);
2554
- };
2555
- const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
2556
- _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
2557
- const {
2558
- attributes
2559
- } = currentNode;
2560
- if (!attributes || _isClobbered(currentNode)) {
2561
- return;
2562
- }
2563
- const hookEvent = {
2564
- attrName: "",
2565
- attrValue: "",
2566
- keepAttr: true,
2567
- allowedAttributes: ALLOWED_ATTR,
2568
- forceKeepAttr: void 0
2569
- };
2570
- let l = attributes.length;
2571
- while (l--) {
2572
- const attr = attributes[l];
2573
- const {
2574
- name,
2575
- namespaceURI,
2576
- value: attrValue
2577
- } = attr;
2578
- const lcName = transformCaseFunc(name);
2579
- const initValue = attrValue;
2580
- let value = name === "value" ? initValue : stringTrim(initValue);
2581
- hookEvent.attrName = lcName;
2582
- hookEvent.attrValue = value;
2583
- hookEvent.keepAttr = true;
2584
- hookEvent.forceKeepAttr = void 0;
2585
- _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
2586
- value = hookEvent.attrValue;
2587
- if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name")) {
2588
- _removeAttribute(name, currentNode);
2589
- value = SANITIZE_NAMED_PROPS_PREFIX + value;
2590
- }
2591
- if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, value)) {
2592
- _removeAttribute(name, currentNode);
2593
- continue;
2594
- }
2595
- if (lcName === "attributename" && stringMatch(value, "href")) {
2596
- _removeAttribute(name, currentNode);
2597
- continue;
2598
- }
2599
- if (hookEvent.forceKeepAttr) {
2600
- continue;
2601
- }
2602
- if (!hookEvent.keepAttr) {
2603
- _removeAttribute(name, currentNode);
2604
- continue;
2605
- }
2606
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
2607
- _removeAttribute(name, currentNode);
2608
- continue;
2609
- }
2610
- if (SAFE_FOR_TEMPLATES) {
2611
- arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
2612
- value = stringReplace(value, expr, " ");
2613
- });
2614
- }
2615
- const lcTag = transformCaseFunc(currentNode.nodeName);
2616
- if (!_isValidAttribute(lcTag, lcName, value)) {
2617
- _removeAttribute(name, currentNode);
2618
- continue;
2619
- }
2620
- if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
2621
- if (namespaceURI) ;
2622
- else {
2623
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2624
- case "TrustedHTML": {
2625
- value = trustedTypesPolicy.createHTML(value);
2626
- break;
2627
- }
2628
- case "TrustedScriptURL": {
2629
- value = trustedTypesPolicy.createScriptURL(value);
2630
- break;
2631
- }
2632
- }
2633
- }
2634
- }
2635
- if (value !== initValue) {
2636
- try {
2637
- if (namespaceURI) {
2638
- currentNode.setAttributeNS(namespaceURI, name, value);
2639
- } else {
2640
- currentNode.setAttribute(name, value);
2615
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2616
+ case "TrustedHTML": {
2617
+ value = trustedTypesPolicy.createHTML(value);
2618
+ break;
2641
2619
  }
2642
- if (_isClobbered(currentNode)) {
2643
- _forceRemove(currentNode);
2644
- } else {
2645
- arrayPop(DOMPurify2.removed);
2620
+ case "TrustedScriptURL": {
2621
+ value = trustedTypesPolicy.createScriptURL(value);
2622
+ break;
2646
2623
  }
2647
- } catch (_) {
2648
- _removeAttribute(name, currentNode);
2649
2624
  }
2650
2625
  }
2651
2626
  }
2652
- _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
2653
- };
2654
- const _sanitizeShadowDOM = function _sanitizeShadowDOM2(fragment) {
2655
- let shadowNode = null;
2656
- const shadowIterator = _createNodeIterator(fragment);
2657
- _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
2658
- while (shadowNode = shadowIterator.nextNode()) {
2659
- _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
2660
- _sanitizeElements(shadowNode);
2661
- _sanitizeAttributes(shadowNode);
2662
- if (shadowNode.content instanceof DocumentFragment) {
2663
- _sanitizeShadowDOM2(shadowNode.content);
2664
- }
2665
- }
2666
- _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
2667
- };
2668
- DOMPurify2.sanitize = function(dirty) {
2669
- let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2670
- let body = null;
2671
- let importedNode = null;
2672
- let currentNode = null;
2673
- let returnNode = null;
2674
- IS_EMPTY_INPUT = !dirty;
2675
- if (IS_EMPTY_INPUT) {
2676
- dirty = "<!-->";
2677
- }
2678
- if (typeof dirty !== "string" && !_isNode(dirty)) {
2679
- if (typeof dirty.toString === "function") {
2680
- dirty = dirty.toString();
2681
- if (typeof dirty !== "string") {
2682
- throw typeErrorCreate("dirty is not a string, aborting");
2627
+ if (value !== initValue) {
2628
+ try {
2629
+ if (namespaceURI) {
2630
+ currentNode.setAttributeNS(namespaceURI, name, value);
2631
+ } else {
2632
+ currentNode.setAttribute(name, value);
2683
2633
  }
2684
- } else {
2685
- throw typeErrorCreate("toString is not a function");
2686
- }
2687
- }
2688
- if (!DOMPurify2.isSupported) {
2689
- return dirty;
2690
- }
2691
- if (!SET_CONFIG) {
2692
- _parseConfig(cfg);
2693
- }
2694
- DOMPurify2.removed = [];
2695
- if (typeof dirty === "string") {
2696
- IN_PLACE = false;
2697
- }
2698
- if (IN_PLACE) {
2699
- if (dirty.nodeName) {
2700
- const tagName = transformCaseFunc(dirty.nodeName);
2701
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
2702
- throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
2634
+ if (_isClobbered(currentNode)) {
2635
+ _forceRemove(currentNode);
2636
+ } else {
2637
+ arrayPop(DOMPurify.removed);
2703
2638
  }
2639
+ } catch (_) {
2640
+ _removeAttribute(name, currentNode);
2704
2641
  }
2705
- } else if (dirty instanceof Node) {
2706
- body = _initDocument("<!---->");
2707
- importedNode = body.ownerDocument.importNode(dirty, true);
2708
- if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") {
2709
- body = importedNode;
2710
- } else if (importedNode.nodeName === "HTML") {
2711
- body = importedNode;
2712
- } else {
2713
- body.appendChild(importedNode);
2642
+ }
2643
+ }
2644
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
2645
+ };
2646
+ const _sanitizeShadowDOM = function _sanitizeShadowDOM2(fragment) {
2647
+ let shadowNode = null;
2648
+ const shadowIterator = _createNodeIterator(fragment);
2649
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
2650
+ while (shadowNode = shadowIterator.nextNode()) {
2651
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
2652
+ _sanitizeElements(shadowNode);
2653
+ _sanitizeAttributes(shadowNode);
2654
+ if (shadowNode.content instanceof DocumentFragment) {
2655
+ _sanitizeShadowDOM2(shadowNode.content);
2656
+ }
2657
+ }
2658
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
2659
+ };
2660
+ DOMPurify.sanitize = function(dirty) {
2661
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2662
+ let body = null;
2663
+ let importedNode = null;
2664
+ let currentNode = null;
2665
+ let returnNode = null;
2666
+ IS_EMPTY_INPUT = !dirty;
2667
+ if (IS_EMPTY_INPUT) {
2668
+ dirty = "<!-->";
2669
+ }
2670
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
2671
+ if (typeof dirty.toString === "function") {
2672
+ dirty = dirty.toString();
2673
+ if (typeof dirty !== "string") {
2674
+ throw typeErrorCreate("dirty is not a string, aborting");
2714
2675
  }
2715
2676
  } else {
2716
- if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
2717
- dirty.indexOf("<") === -1) {
2718
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
2719
- }
2720
- body = _initDocument(dirty);
2721
- if (!body) {
2722
- return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
2723
- }
2724
- }
2725
- if (body && FORCE_BODY) {
2726
- _forceRemove(body.firstChild);
2677
+ throw typeErrorCreate("toString is not a function");
2727
2678
  }
2728
- const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
2729
- while (currentNode = nodeIterator.nextNode()) {
2730
- _sanitizeElements(currentNode);
2731
- _sanitizeAttributes(currentNode);
2732
- if (currentNode.content instanceof DocumentFragment) {
2733
- _sanitizeShadowDOM(currentNode.content);
2679
+ }
2680
+ if (!DOMPurify.isSupported) {
2681
+ return dirty;
2682
+ }
2683
+ if (!SET_CONFIG) {
2684
+ _parseConfig(cfg);
2685
+ }
2686
+ DOMPurify.removed = [];
2687
+ if (typeof dirty === "string") {
2688
+ IN_PLACE = false;
2689
+ }
2690
+ if (IN_PLACE) {
2691
+ if (dirty.nodeName) {
2692
+ const tagName = transformCaseFunc(dirty.nodeName);
2693
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
2694
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
2734
2695
  }
2735
2696
  }
2736
- if (IN_PLACE) {
2737
- return dirty;
2697
+ } else if (dirty instanceof Node) {
2698
+ body = _initDocument("<!---->");
2699
+ importedNode = body.ownerDocument.importNode(dirty, true);
2700
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") {
2701
+ body = importedNode;
2702
+ } else if (importedNode.nodeName === "HTML") {
2703
+ body = importedNode;
2704
+ } else {
2705
+ body.appendChild(importedNode);
2738
2706
  }
2739
- if (RETURN_DOM) {
2740
- if (RETURN_DOM_FRAGMENT) {
2741
- returnNode = createDocumentFragment.call(body.ownerDocument);
2742
- while (body.firstChild) {
2743
- returnNode.appendChild(body.firstChild);
2744
- }
2745
- } else {
2746
- returnNode = body;
2747
- }
2748
- if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
2749
- returnNode = importNode.call(originalDocument, returnNode, true);
2750
- }
2751
- return returnNode;
2707
+ } else {
2708
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
2709
+ dirty.indexOf("<") === -1) {
2710
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
2752
2711
  }
2753
- let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
2754
- if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
2755
- serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
2712
+ body = _initDocument(dirty);
2713
+ if (!body) {
2714
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
2756
2715
  }
2757
- if (SAFE_FOR_TEMPLATES) {
2758
- arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
2759
- serializedHTML = stringReplace(serializedHTML, expr, " ");
2760
- });
2761
- }
2762
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
2763
- };
2764
- DOMPurify2.setConfig = function() {
2765
- let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2766
- _parseConfig(cfg);
2767
- SET_CONFIG = true;
2768
- };
2769
- DOMPurify2.clearConfig = function() {
2770
- CONFIG = null;
2771
- SET_CONFIG = false;
2772
- };
2773
- DOMPurify2.isValidAttribute = function(tag2, attr, value) {
2774
- if (!CONFIG) {
2775
- _parseConfig({});
2716
+ }
2717
+ if (body && FORCE_BODY) {
2718
+ _forceRemove(body.firstChild);
2719
+ }
2720
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
2721
+ while (currentNode = nodeIterator.nextNode()) {
2722
+ _sanitizeElements(currentNode);
2723
+ _sanitizeAttributes(currentNode);
2724
+ if (currentNode.content instanceof DocumentFragment) {
2725
+ _sanitizeShadowDOM(currentNode.content);
2776
2726
  }
2777
- const lcTag = transformCaseFunc(tag2);
2778
- const lcName = transformCaseFunc(attr);
2779
- return _isValidAttribute(lcTag, lcName, value);
2780
- };
2781
- DOMPurify2.addHook = function(entryPoint, hookFunction) {
2782
- if (typeof hookFunction !== "function") {
2783
- return;
2727
+ }
2728
+ if (IN_PLACE) {
2729
+ return dirty;
2730
+ }
2731
+ if (RETURN_DOM) {
2732
+ if (RETURN_DOM_FRAGMENT) {
2733
+ returnNode = createDocumentFragment.call(body.ownerDocument);
2734
+ while (body.firstChild) {
2735
+ returnNode.appendChild(body.firstChild);
2736
+ }
2737
+ } else {
2738
+ returnNode = body;
2784
2739
  }
2785
- arrayPush(hooks[entryPoint], hookFunction);
2786
- };
2787
- DOMPurify2.removeHook = function(entryPoint, hookFunction) {
2788
- if (hookFunction !== void 0) {
2789
- const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
2790
- return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
2740
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
2741
+ returnNode = importNode.call(originalDocument, returnNode, true);
2791
2742
  }
2792
- return arrayPop(hooks[entryPoint]);
2793
- };
2794
- DOMPurify2.removeHooks = function(entryPoint) {
2795
- hooks[entryPoint] = [];
2796
- };
2797
- DOMPurify2.removeAllHooks = function() {
2798
- hooks = _createHooksMap();
2799
- };
2800
- return DOMPurify2;
2801
- }
2802
- var purify = createDOMPurify();
2803
- purify_cjs = purify;
2804
- return purify_cjs;
2743
+ return returnNode;
2744
+ }
2745
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
2746
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
2747
+ serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
2748
+ }
2749
+ if (SAFE_FOR_TEMPLATES) {
2750
+ arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
2751
+ serializedHTML = stringReplace(serializedHTML, expr, " ");
2752
+ });
2753
+ }
2754
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
2755
+ };
2756
+ DOMPurify.setConfig = function() {
2757
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2758
+ _parseConfig(cfg);
2759
+ SET_CONFIG = true;
2760
+ };
2761
+ DOMPurify.clearConfig = function() {
2762
+ CONFIG = null;
2763
+ SET_CONFIG = false;
2764
+ };
2765
+ DOMPurify.isValidAttribute = function(tag2, attr, value) {
2766
+ if (!CONFIG) {
2767
+ _parseConfig({});
2768
+ }
2769
+ const lcTag = transformCaseFunc(tag2);
2770
+ const lcName = transformCaseFunc(attr);
2771
+ return _isValidAttribute(lcTag, lcName, value);
2772
+ };
2773
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
2774
+ if (typeof hookFunction !== "function") {
2775
+ return;
2776
+ }
2777
+ arrayPush(hooks[entryPoint], hookFunction);
2778
+ };
2779
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
2780
+ if (hookFunction !== void 0) {
2781
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
2782
+ return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
2783
+ }
2784
+ return arrayPop(hooks[entryPoint]);
2785
+ };
2786
+ DOMPurify.removeHooks = function(entryPoint) {
2787
+ hooks[entryPoint] = [];
2788
+ };
2789
+ DOMPurify.removeAllHooks = function() {
2790
+ hooks = _createHooksMap();
2791
+ };
2792
+ return DOMPurify;
2805
2793
  }
2806
- var browser = window.DOMPurify || (window.DOMPurify = requirePurify_cjs().default || requirePurify_cjs());
2807
- const DOMPurify = /* @__PURE__ */ getDefaultExportFromCjs(browser);
2808
- function sanitizeHtml(html, options) {
2794
+ var purify = createDOMPurify();
2795
+ function sanitizeHtml(html2, options) {
2809
2796
  const defaultOptions = {
2810
2797
  ALLOWED_TAGS: ["a", "b", "strong", "i", "em", "u", "br", "p", "span"],
2811
2798
  ALLOWED_ATTR: ["href", "target", "rel"],
@@ -2820,11 +2807,11 @@ function sanitizeHtml(html, options) {
2820
2807
  )
2821
2808
  }
2822
2809
  };
2823
- return String(DOMPurify.sanitize(html, config));
2810
+ return String(purify.sanitize(html2, config));
2824
2811
  }
2825
- function linkifyText(text) {
2812
+ function linkifyText(text2) {
2826
2813
  const urlRegex = /(https?:\/\/[^\s]+)/g;
2827
- const linked = text.replace(
2814
+ const linked = text2.replace(
2828
2815
  urlRegex,
2829
2816
  '<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>'
2830
2817
  );
@@ -2833,8 +2820,8 @@ function linkifyText(text) {
2833
2820
  allowedAttributes: { a: ["href", "target", "rel"] }
2834
2821
  });
2835
2822
  }
2836
- function safeLinkifyText(text) {
2837
- return linkifyText(text);
2823
+ function safeLinkifyText(text2) {
2824
+ return linkifyText(text2);
2838
2825
  }
2839
2826
  export {
2840
2827
  ChatResolvedError as C,
@@ -2844,4 +2831,4 @@ export {
2844
2831
  linkifyText as l,
2845
2832
  sendDialogflowMessage as s
2846
2833
  };
2847
- //# sourceMappingURL=sanitize-BNRb-K3t.mjs.map
2834
+ //# sourceMappingURL=sanitize-DA2IXhv_.mjs.map