@bigbinary/neeto-molecules 3.13.13 → 3.13.15

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.
@@ -30,6 +30,1629 @@ function _interopNamespaceDefault(e) {
30
30
 
31
31
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
32
32
 
33
+ /*! @license DOMPurify 3.0.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.3/LICENSE */
34
+
35
+ const {
36
+ entries,
37
+ setPrototypeOf,
38
+ isFrozen,
39
+ getPrototypeOf,
40
+ getOwnPropertyDescriptor
41
+ } = Object;
42
+ let {
43
+ freeze,
44
+ seal,
45
+ create
46
+ } = Object; // eslint-disable-line import/no-mutable-exports
47
+
48
+ let {
49
+ apply,
50
+ construct
51
+ } = typeof Reflect !== 'undefined' && Reflect;
52
+
53
+ if (!apply) {
54
+ apply = function apply(fun, thisValue, args) {
55
+ return fun.apply(thisValue, args);
56
+ };
57
+ }
58
+
59
+ if (!freeze) {
60
+ freeze = function freeze(x) {
61
+ return x;
62
+ };
63
+ }
64
+
65
+ if (!seal) {
66
+ seal = function seal(x) {
67
+ return x;
68
+ };
69
+ }
70
+
71
+ if (!construct) {
72
+ construct = function construct(Func, args) {
73
+ return new Func(...args);
74
+ };
75
+ }
76
+
77
+ const arrayForEach = unapply(Array.prototype.forEach);
78
+ const arrayPop = unapply(Array.prototype.pop);
79
+ const arrayPush = unapply(Array.prototype.push);
80
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
81
+ const stringToString = unapply(String.prototype.toString);
82
+ const stringMatch = unapply(String.prototype.match);
83
+ const stringReplace = unapply(String.prototype.replace);
84
+ const stringIndexOf = unapply(String.prototype.indexOf);
85
+ const stringTrim = unapply(String.prototype.trim);
86
+ const regExpTest = unapply(RegExp.prototype.test);
87
+ const typeErrorCreate = unconstruct(TypeError);
88
+ function unapply(func) {
89
+ return function (thisArg) {
90
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
91
+ args[_key - 1] = arguments[_key];
92
+ }
93
+
94
+ return apply(func, thisArg, args);
95
+ };
96
+ }
97
+ function unconstruct(func) {
98
+ return function () {
99
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
100
+ args[_key2] = arguments[_key2];
101
+ }
102
+
103
+ return construct(func, args);
104
+ };
105
+ }
106
+ /* Add properties to a lookup table */
107
+
108
+ function addToSet(set, array, transformCaseFunc) {
109
+ var _transformCaseFunc;
110
+
111
+ transformCaseFunc = (_transformCaseFunc = transformCaseFunc) !== null && _transformCaseFunc !== void 0 ? _transformCaseFunc : stringToLowerCase;
112
+
113
+ if (setPrototypeOf) {
114
+ // Make 'in' and truthy checks like Boolean(set.constructor)
115
+ // independent of any properties defined on Object.prototype.
116
+ // Prevent prototype setters from intercepting set as a this value.
117
+ setPrototypeOf(set, null);
118
+ }
119
+
120
+ let l = array.length;
121
+
122
+ while (l--) {
123
+ let element = array[l];
124
+
125
+ if (typeof element === 'string') {
126
+ const lcElement = transformCaseFunc(element);
127
+
128
+ if (lcElement !== element) {
129
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
130
+ if (!isFrozen(array)) {
131
+ array[l] = lcElement;
132
+ }
133
+
134
+ element = lcElement;
135
+ }
136
+ }
137
+
138
+ set[element] = true;
139
+ }
140
+
141
+ return set;
142
+ }
143
+ /* Shallow clone an object */
144
+
145
+ function clone(object) {
146
+ const newObject = create(null);
147
+
148
+ for (const [property, value] of entries(object)) {
149
+ newObject[property] = value;
150
+ }
151
+
152
+ return newObject;
153
+ }
154
+ /* This method automatically checks if the prop is function
155
+ * or getter and behaves accordingly. */
156
+
157
+ function lookupGetter(object, prop) {
158
+ while (object !== null) {
159
+ const desc = getOwnPropertyDescriptor(object, prop);
160
+
161
+ if (desc) {
162
+ if (desc.get) {
163
+ return unapply(desc.get);
164
+ }
165
+
166
+ if (typeof desc.value === 'function') {
167
+ return unapply(desc.value);
168
+ }
169
+ }
170
+
171
+ object = getPrototypeOf(object);
172
+ }
173
+
174
+ function fallbackValue(element) {
175
+ console.warn('fallback value for', element);
176
+ return null;
177
+ }
178
+
179
+ return fallbackValue;
180
+ }
181
+
182
+ 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', 'section', 'select', 'shadow', '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']); // SVG
183
+
184
+ const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
185
+ 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']); // List of SVG elements that are disallowed by default.
186
+ // We still need to know them so that we can do namespace
187
+ // checks properly in case one wants to add them to
188
+ // allow-list.
189
+
190
+ 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']);
191
+ 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']); // Similarly to SVG, we want to know all MathML elements,
192
+ // even those that we disallow by default.
193
+
194
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
195
+ const text = freeze(['#text']);
196
+
197
+ 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', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', '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', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
198
+ const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', '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', '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', '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', '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', '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', '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']);
199
+ 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']);
200
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
201
+
202
+ const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
203
+
204
+ const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
205
+ const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
206
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
207
+
208
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
209
+
210
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
211
+ );
212
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
213
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
214
+ );
215
+ const DOCTYPE_NAME = seal(/^html$/i);
216
+
217
+ var EXPRESSIONS = /*#__PURE__*/Object.freeze({
218
+ __proto__: null,
219
+ MUSTACHE_EXPR: MUSTACHE_EXPR,
220
+ ERB_EXPR: ERB_EXPR,
221
+ TMPLIT_EXPR: TMPLIT_EXPR,
222
+ DATA_ATTR: DATA_ATTR,
223
+ ARIA_ATTR: ARIA_ATTR,
224
+ IS_ALLOWED_URI: IS_ALLOWED_URI,
225
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
226
+ ATTR_WHITESPACE: ATTR_WHITESPACE,
227
+ DOCTYPE_NAME: DOCTYPE_NAME
228
+ });
229
+
230
+ const getGlobal = () => typeof window === 'undefined' ? null : window;
231
+ /**
232
+ * Creates a no-op policy for internal use only.
233
+ * Don't export this function outside this module!
234
+ * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
235
+ * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
236
+ * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
237
+ * are not supported or creating the policy failed).
238
+ */
239
+
240
+
241
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
242
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
243
+ return null;
244
+ } // Allow the callers to control the unique policy name
245
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
246
+ // Policy creation with duplicate names throws in Trusted Types.
247
+
248
+
249
+ let suffix = null;
250
+ const ATTR_NAME = 'data-tt-policy-suffix';
251
+
252
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
253
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
254
+ }
255
+
256
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
257
+
258
+ try {
259
+ return trustedTypes.createPolicy(policyName, {
260
+ createHTML(html) {
261
+ return html;
262
+ },
263
+
264
+ createScriptURL(scriptUrl) {
265
+ return scriptUrl;
266
+ }
267
+
268
+ });
269
+ } catch (_) {
270
+ // Policy creation failed (most likely another DOMPurify script has
271
+ // already run). Skip creating the policy, as this will only cause errors
272
+ // if TT are enforced.
273
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
274
+ return null;
275
+ }
276
+ };
277
+
278
+ function createDOMPurify() {
279
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
280
+
281
+ const DOMPurify = root => createDOMPurify(root);
282
+ /**
283
+ * Version label, exposed for easier checks
284
+ * if DOMPurify is up to date or not
285
+ */
286
+
287
+
288
+ DOMPurify.version = '3.0.3';
289
+ /**
290
+ * Array of elements that DOMPurify removed during sanitation.
291
+ * Empty if nothing was removed.
292
+ */
293
+
294
+ DOMPurify.removed = [];
295
+
296
+ if (!window || !window.document || window.document.nodeType !== 9) {
297
+ // Not running in a browser, provide a factory function
298
+ // so that you can pass your own Window
299
+ DOMPurify.isSupported = false;
300
+ return DOMPurify;
301
+ }
302
+
303
+ const originalDocument = window.document;
304
+ const currentScript = originalDocument.currentScript;
305
+ let {
306
+ document
307
+ } = window;
308
+ const {
309
+ DocumentFragment,
310
+ HTMLTemplateElement,
311
+ Node,
312
+ Element,
313
+ NodeFilter,
314
+ NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
315
+ HTMLFormElement,
316
+ DOMParser,
317
+ trustedTypes
318
+ } = window;
319
+ const ElementPrototype = Element.prototype;
320
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
321
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
322
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
323
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a
324
+ // new document created via createHTMLDocument. As per the spec
325
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
326
+ // a new empty registry is used when creating a template contents owner
327
+ // document, so we use that as our parent document to ensure nothing
328
+ // is inherited.
329
+
330
+ if (typeof HTMLTemplateElement === 'function') {
331
+ const template = document.createElement('template');
332
+
333
+ if (template.content && template.content.ownerDocument) {
334
+ document = template.content.ownerDocument;
335
+ }
336
+ }
337
+
338
+ let trustedTypesPolicy;
339
+ let emptyHTML = '';
340
+ const {
341
+ implementation,
342
+ createNodeIterator,
343
+ createDocumentFragment,
344
+ getElementsByTagName
345
+ } = document;
346
+ const {
347
+ importNode
348
+ } = originalDocument;
349
+ let hooks = {};
350
+ /**
351
+ * Expose whether this browser supports running the full DOMPurify.
352
+ */
353
+
354
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
355
+ const {
356
+ MUSTACHE_EXPR,
357
+ ERB_EXPR,
358
+ TMPLIT_EXPR,
359
+ DATA_ATTR,
360
+ ARIA_ATTR,
361
+ IS_SCRIPT_OR_DATA,
362
+ ATTR_WHITESPACE
363
+ } = EXPRESSIONS;
364
+ let {
365
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
366
+ } = EXPRESSIONS;
367
+ /**
368
+ * We consider the elements and attributes below to be safe. Ideally
369
+ * don't add any new ones but feel free to remove unwanted ones.
370
+ */
371
+
372
+ /* allowed element names */
373
+
374
+ let ALLOWED_TAGS = null;
375
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
376
+ /* Allowed attribute names */
377
+
378
+ let ALLOWED_ATTR = null;
379
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
380
+ /*
381
+ * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
382
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
383
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
384
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
385
+ */
386
+
387
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
388
+ tagNameCheck: {
389
+ writable: true,
390
+ configurable: false,
391
+ enumerable: true,
392
+ value: null
393
+ },
394
+ attributeNameCheck: {
395
+ writable: true,
396
+ configurable: false,
397
+ enumerable: true,
398
+ value: null
399
+ },
400
+ allowCustomizedBuiltInElements: {
401
+ writable: true,
402
+ configurable: false,
403
+ enumerable: true,
404
+ value: false
405
+ }
406
+ }));
407
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
408
+
409
+ let FORBID_TAGS = null;
410
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
411
+
412
+ let FORBID_ATTR = null;
413
+ /* Decide if ARIA attributes are okay */
414
+
415
+ let ALLOW_ARIA_ATTR = true;
416
+ /* Decide if custom data attributes are okay */
417
+
418
+ let ALLOW_DATA_ATTR = true;
419
+ /* Decide if unknown protocols are okay */
420
+
421
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
422
+ /* Decide if self-closing tags in attributes are allowed.
423
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
424
+
425
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
426
+ /* Output should be safe for common template engines.
427
+ * This means, DOMPurify removes data attributes, mustaches and ERB
428
+ */
429
+
430
+ let SAFE_FOR_TEMPLATES = false;
431
+ /* Decide if document with <html>... should be returned */
432
+
433
+ let WHOLE_DOCUMENT = false;
434
+ /* Track whether config is already set on this instance of DOMPurify. */
435
+
436
+ let SET_CONFIG = false;
437
+ /* Decide if all elements (e.g. style, script) must be children of
438
+ * document.body. By default, browsers might move them to document.head */
439
+
440
+ let FORCE_BODY = false;
441
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
442
+ * string (or a TrustedHTML object if Trusted Types are supported).
443
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
444
+ */
445
+
446
+ let RETURN_DOM = false;
447
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
448
+ * string (or a TrustedHTML object if Trusted Types are supported) */
449
+
450
+ let RETURN_DOM_FRAGMENT = false;
451
+ /* Try to return a Trusted Type object instead of a string, return a string in
452
+ * case Trusted Types are not supported */
453
+
454
+ let RETURN_TRUSTED_TYPE = false;
455
+ /* Output should be free from DOM clobbering attacks?
456
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
457
+ */
458
+
459
+ let SANITIZE_DOM = true;
460
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
461
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
462
+ *
463
+ * HTML/DOM spec rules that enable DOM Clobbering:
464
+ * - Named Access on Window (§7.3.3)
465
+ * - DOM Tree Accessors (§3.1.5)
466
+ * - Form Element Parent-Child Relations (§4.10.3)
467
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
468
+ * - HTMLCollection (§4.2.10.2)
469
+ *
470
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
471
+ * with a constant string, i.e., `user-content-`
472
+ */
473
+
474
+ let SANITIZE_NAMED_PROPS = false;
475
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
476
+ /* Keep element content when removing element? */
477
+
478
+ let KEEP_CONTENT = true;
479
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
480
+ * of importing it into a new Document and returning a sanitized copy */
481
+
482
+ let IN_PLACE = false;
483
+ /* Allow usage of profiles like html, svg and mathMl */
484
+
485
+ let USE_PROFILES = {};
486
+ /* Tags to ignore content of when KEEP_CONTENT is true */
487
+
488
+ let FORBID_CONTENTS = null;
489
+ 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']);
490
+ /* Tags that are safe for data: URIs */
491
+
492
+ let DATA_URI_TAGS = null;
493
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
494
+ /* Attributes safe for values like "javascript:" */
495
+
496
+ let URI_SAFE_ATTRIBUTES = null;
497
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
498
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
499
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
500
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
501
+ /* Document namespace */
502
+
503
+ let NAMESPACE = HTML_NAMESPACE;
504
+ let IS_EMPTY_INPUT = false;
505
+ /* Allowed XHTML+XML namespaces */
506
+
507
+ let ALLOWED_NAMESPACES = null;
508
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
509
+ /* Parsing of strict XHTML documents */
510
+
511
+ let PARSER_MEDIA_TYPE;
512
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
513
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
514
+ let transformCaseFunc;
515
+ /* Keep a reference to config to pass to hooks */
516
+
517
+ let CONFIG = null;
518
+ /* Ideally, do not touch anything below this line */
519
+
520
+ /* ______________________________________________ */
521
+
522
+ const formElement = document.createElement('form');
523
+
524
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
525
+ return testValue instanceof RegExp || testValue instanceof Function;
526
+ };
527
+ /**
528
+ * _parseConfig
529
+ *
530
+ * @param {Object} cfg optional config literal
531
+ */
532
+ // eslint-disable-next-line complexity
533
+
534
+
535
+ const _parseConfig = function _parseConfig(cfg) {
536
+ if (CONFIG && CONFIG === cfg) {
537
+ return;
538
+ }
539
+ /* Shield configuration object from tampering */
540
+
541
+
542
+ if (!cfg || typeof cfg !== 'object') {
543
+ cfg = {};
544
+ }
545
+ /* Shield configuration object from prototype pollution */
546
+
547
+
548
+ cfg = clone(cfg);
549
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
550
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
551
+
552
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
553
+ /* Set configuration parameters */
554
+
555
+ ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
556
+ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
557
+ ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
558
+ URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent
559
+ cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent
560
+ transformCaseFunc // eslint-disable-line indent
561
+ ) // eslint-disable-line indent
562
+ : DEFAULT_URI_SAFE_ATTRIBUTES;
563
+ DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent
564
+ cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent
565
+ transformCaseFunc // eslint-disable-line indent
566
+ ) // eslint-disable-line indent
567
+ : DEFAULT_DATA_URI_TAGS;
568
+ FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
569
+ FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
570
+ FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
571
+ USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
572
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
573
+
574
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
575
+
576
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
577
+
578
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
579
+
580
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
581
+
582
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
583
+
584
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
585
+
586
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
587
+
588
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
589
+
590
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
591
+
592
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
593
+
594
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
595
+
596
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
597
+
598
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
599
+
600
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
601
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
602
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
603
+
604
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
605
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
606
+ }
607
+
608
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
609
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
610
+ }
611
+
612
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
613
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
614
+ }
615
+
616
+ if (SAFE_FOR_TEMPLATES) {
617
+ ALLOW_DATA_ATTR = false;
618
+ }
619
+
620
+ if (RETURN_DOM_FRAGMENT) {
621
+ RETURN_DOM = true;
622
+ }
623
+ /* Parse profile info */
624
+
625
+
626
+ if (USE_PROFILES) {
627
+ ALLOWED_TAGS = addToSet({}, [...text]);
628
+ ALLOWED_ATTR = [];
629
+
630
+ if (USE_PROFILES.html === true) {
631
+ addToSet(ALLOWED_TAGS, html$1);
632
+ addToSet(ALLOWED_ATTR, html);
633
+ }
634
+
635
+ if (USE_PROFILES.svg === true) {
636
+ addToSet(ALLOWED_TAGS, svg$1);
637
+ addToSet(ALLOWED_ATTR, svg);
638
+ addToSet(ALLOWED_ATTR, xml);
639
+ }
640
+
641
+ if (USE_PROFILES.svgFilters === true) {
642
+ addToSet(ALLOWED_TAGS, svgFilters);
643
+ addToSet(ALLOWED_ATTR, svg);
644
+ addToSet(ALLOWED_ATTR, xml);
645
+ }
646
+
647
+ if (USE_PROFILES.mathMl === true) {
648
+ addToSet(ALLOWED_TAGS, mathMl$1);
649
+ addToSet(ALLOWED_ATTR, mathMl);
650
+ addToSet(ALLOWED_ATTR, xml);
651
+ }
652
+ }
653
+ /* Merge configuration parameters */
654
+
655
+
656
+ if (cfg.ADD_TAGS) {
657
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
658
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
659
+ }
660
+
661
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
662
+ }
663
+
664
+ if (cfg.ADD_ATTR) {
665
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
666
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
667
+ }
668
+
669
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
670
+ }
671
+
672
+ if (cfg.ADD_URI_SAFE_ATTR) {
673
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
674
+ }
675
+
676
+ if (cfg.FORBID_CONTENTS) {
677
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
678
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
679
+ }
680
+
681
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
682
+ }
683
+ /* Add #text in case KEEP_CONTENT is set to true */
684
+
685
+
686
+ if (KEEP_CONTENT) {
687
+ ALLOWED_TAGS['#text'] = true;
688
+ }
689
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
690
+
691
+
692
+ if (WHOLE_DOCUMENT) {
693
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
694
+ }
695
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
696
+
697
+
698
+ if (ALLOWED_TAGS.table) {
699
+ addToSet(ALLOWED_TAGS, ['tbody']);
700
+ delete FORBID_TAGS.tbody;
701
+ }
702
+
703
+ if (cfg.TRUSTED_TYPES_POLICY) {
704
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
705
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
706
+ }
707
+
708
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
709
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
710
+ } // Overwrite existing TrustedTypes policy.
711
+
712
+
713
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; // Sign local variables required by `sanitize`.
714
+
715
+ emptyHTML = trustedTypesPolicy.createHTML('');
716
+ } else {
717
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
718
+ if (trustedTypesPolicy === undefined) {
719
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
720
+ } // If creating the internal policy succeeded sign internal variables.
721
+
722
+
723
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
724
+ emptyHTML = trustedTypesPolicy.createHTML('');
725
+ }
726
+ } // Prevent further manipulation of configuration.
727
+ // Not available in IE8, Safari 5, etc.
728
+
729
+
730
+ if (freeze) {
731
+ freeze(cfg);
732
+ }
733
+
734
+ CONFIG = cfg;
735
+ };
736
+
737
+ const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
738
+ const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML
739
+ // namespace. We need to specify them explicitly
740
+ // so that they don't get erroneously deleted from
741
+ // HTML namespace.
742
+
743
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
744
+ /* Keep track of all possible SVG and MathML tags
745
+ * so that we can perform the namespace checks
746
+ * correctly. */
747
+
748
+ const ALL_SVG_TAGS = addToSet({}, svg$1);
749
+ addToSet(ALL_SVG_TAGS, svgFilters);
750
+ addToSet(ALL_SVG_TAGS, svgDisallowed);
751
+ const ALL_MATHML_TAGS = addToSet({}, mathMl$1);
752
+ addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
753
+ /**
754
+ *
755
+ *
756
+ * @param {Element} element a DOM element whose namespace is being checked
757
+ * @returns {boolean} Return false if the element has a
758
+ * namespace that a spec-compliant parser would never
759
+ * return. Return true otherwise.
760
+ */
761
+
762
+ const _checkValidNamespace = function _checkValidNamespace(element) {
763
+ let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
764
+ // can be null. We just simulate parent in this case.
765
+
766
+ if (!parent || !parent.tagName) {
767
+ parent = {
768
+ namespaceURI: NAMESPACE,
769
+ tagName: 'template'
770
+ };
771
+ }
772
+
773
+ const tagName = stringToLowerCase(element.tagName);
774
+ const parentTagName = stringToLowerCase(parent.tagName);
775
+
776
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
777
+ return false;
778
+ }
779
+
780
+ if (element.namespaceURI === SVG_NAMESPACE) {
781
+ // The only way to switch from HTML namespace to SVG
782
+ // is via <svg>. If it happens via any other tag, then
783
+ // it should be killed.
784
+ if (parent.namespaceURI === HTML_NAMESPACE) {
785
+ return tagName === 'svg';
786
+ } // The only way to switch from MathML to SVG is via`
787
+ // svg if parent is either <annotation-xml> or MathML
788
+ // text integration points.
789
+
790
+
791
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
792
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
793
+ } // We only allow elements that are defined in SVG
794
+ // spec. All others are disallowed in SVG namespace.
795
+
796
+
797
+ return Boolean(ALL_SVG_TAGS[tagName]);
798
+ }
799
+
800
+ if (element.namespaceURI === MATHML_NAMESPACE) {
801
+ // The only way to switch from HTML namespace to MathML
802
+ // is via <math>. If it happens via any other tag, then
803
+ // it should be killed.
804
+ if (parent.namespaceURI === HTML_NAMESPACE) {
805
+ return tagName === 'math';
806
+ } // The only way to switch from SVG to MathML is via
807
+ // <math> and HTML integration points
808
+
809
+
810
+ if (parent.namespaceURI === SVG_NAMESPACE) {
811
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
812
+ } // We only allow elements that are defined in MathML
813
+ // spec. All others are disallowed in MathML namespace.
814
+
815
+
816
+ return Boolean(ALL_MATHML_TAGS[tagName]);
817
+ }
818
+
819
+ if (element.namespaceURI === HTML_NAMESPACE) {
820
+ // The only way to switch from SVG to HTML is via
821
+ // HTML integration points, and from MathML to HTML
822
+ // is via MathML text integration points
823
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
824
+ return false;
825
+ }
826
+
827
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
828
+ return false;
829
+ } // We disallow tags that are specific for MathML
830
+ // or SVG and should never appear in HTML namespace
831
+
832
+
833
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
834
+ } // For XHTML and XML documents that support custom namespaces
835
+
836
+
837
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
838
+ return true;
839
+ } // The code should never reach this place (this means
840
+ // that the element somehow got namespace that is not
841
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
842
+ // Return false just in case.
843
+
844
+
845
+ return false;
846
+ };
847
+ /**
848
+ * _forceRemove
849
+ *
850
+ * @param {Node} node a DOM node
851
+ */
852
+
853
+
854
+ const _forceRemove = function _forceRemove(node) {
855
+ arrayPush(DOMPurify.removed, {
856
+ element: node
857
+ });
858
+
859
+ try {
860
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
861
+ node.parentNode.removeChild(node);
862
+ } catch (_) {
863
+ node.remove();
864
+ }
865
+ };
866
+ /**
867
+ * _removeAttribute
868
+ *
869
+ * @param {String} name an Attribute name
870
+ * @param {Node} node a DOM node
871
+ */
872
+
873
+
874
+ const _removeAttribute = function _removeAttribute(name, node) {
875
+ try {
876
+ arrayPush(DOMPurify.removed, {
877
+ attribute: node.getAttributeNode(name),
878
+ from: node
879
+ });
880
+ } catch (_) {
881
+ arrayPush(DOMPurify.removed, {
882
+ attribute: null,
883
+ from: node
884
+ });
885
+ }
886
+
887
+ node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes
888
+
889
+ if (name === 'is' && !ALLOWED_ATTR[name]) {
890
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
891
+ try {
892
+ _forceRemove(node);
893
+ } catch (_) {}
894
+ } else {
895
+ try {
896
+ node.setAttribute(name, '');
897
+ } catch (_) {}
898
+ }
899
+ }
900
+ };
901
+ /**
902
+ * _initDocument
903
+ *
904
+ * @param {String} dirty a string of dirty markup
905
+ * @return {Document} a DOM, filled with the dirty markup
906
+ */
907
+
908
+
909
+ const _initDocument = function _initDocument(dirty) {
910
+ /* Create a HTML document */
911
+ let doc;
912
+ let leadingWhitespace;
913
+
914
+ if (FORCE_BODY) {
915
+ dirty = '<remove></remove>' + dirty;
916
+ } else {
917
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
918
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
919
+ leadingWhitespace = matches && matches[0];
920
+ }
921
+
922
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
923
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
924
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
925
+ }
926
+
927
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
928
+ /*
929
+ * Use the DOMParser API by default, fallback later if needs be
930
+ * DOMParser not work for svg when has multiple root element.
931
+ */
932
+
933
+ if (NAMESPACE === HTML_NAMESPACE) {
934
+ try {
935
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
936
+ } catch (_) {}
937
+ }
938
+ /* Use createHTMLDocument in case DOMParser is not available */
939
+
940
+
941
+ if (!doc || !doc.documentElement) {
942
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
943
+
944
+ try {
945
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
946
+ } catch (_) {// Syntax error if dirtyPayload is invalid xml
947
+ }
948
+ }
949
+
950
+ const body = doc.body || doc.documentElement;
951
+
952
+ if (dirty && leadingWhitespace) {
953
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
954
+ }
955
+ /* Work on whole document or just its body */
956
+
957
+
958
+ if (NAMESPACE === HTML_NAMESPACE) {
959
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
960
+ }
961
+
962
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
963
+ };
964
+ /**
965
+ * _createIterator
966
+ *
967
+ * @param {Document} root document/fragment to create iterator for
968
+ * @return {Iterator} iterator instance
969
+ */
970
+
971
+
972
+ const _createIterator = function _createIterator(root) {
973
+ return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
974
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
975
+ };
976
+ /**
977
+ * _isClobbered
978
+ *
979
+ * @param {Node} elm element to check for clobbering attacks
980
+ * @return {Boolean} true if clobbered, false if safe
981
+ */
982
+
983
+
984
+ const _isClobbered = function _isClobbered(elm) {
985
+ return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
986
+ };
987
+ /**
988
+ * _isNode
989
+ *
990
+ * @param {Node} obj object to check whether it's a DOM node
991
+ * @return {Boolean} true is object is a DOM node
992
+ */
993
+
994
+
995
+ const _isNode = function _isNode(object) {
996
+ return typeof Node === 'object' ? object instanceof Node : object && typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
997
+ };
998
+ /**
999
+ * _executeHook
1000
+ * Execute user configurable hooks
1001
+ *
1002
+ * @param {String} entryPoint Name of the hook's entry point
1003
+ * @param {Node} currentNode node to work on with the hook
1004
+ * @param {Object} data additional hook parameters
1005
+ */
1006
+
1007
+
1008
+ const _executeHook = function _executeHook(entryPoint, currentNode, data) {
1009
+ if (!hooks[entryPoint]) {
1010
+ return;
1011
+ }
1012
+
1013
+ arrayForEach(hooks[entryPoint], hook => {
1014
+ hook.call(DOMPurify, currentNode, data, CONFIG);
1015
+ });
1016
+ };
1017
+ /**
1018
+ * _sanitizeElements
1019
+ *
1020
+ * @protect nodeName
1021
+ * @protect textContent
1022
+ * @protect removeChild
1023
+ *
1024
+ * @param {Node} currentNode to check for permission to exist
1025
+ * @return {Boolean} true if node was killed, false if left alive
1026
+ */
1027
+
1028
+
1029
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
1030
+ let content;
1031
+ /* Execute a hook if present */
1032
+
1033
+ _executeHook('beforeSanitizeElements', currentNode, null);
1034
+ /* Check if element is clobbered or can clobber */
1035
+
1036
+
1037
+ if (_isClobbered(currentNode)) {
1038
+ _forceRemove(currentNode);
1039
+
1040
+ return true;
1041
+ }
1042
+ /* Now let's check the element's type and name */
1043
+
1044
+
1045
+ const tagName = transformCaseFunc(currentNode.nodeName);
1046
+ /* Execute a hook if present */
1047
+
1048
+ _executeHook('uponSanitizeElement', currentNode, {
1049
+ tagName,
1050
+ allowedTags: ALLOWED_TAGS
1051
+ });
1052
+ /* Detect mXSS attempts abusing namespace confusion */
1053
+
1054
+
1055
+ if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
1056
+ _forceRemove(currentNode);
1057
+
1058
+ return true;
1059
+ }
1060
+ /* Remove element if anything forbids its presence */
1061
+
1062
+
1063
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1064
+ /* Check if we have a custom element to handle */
1065
+ if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
1066
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
1067
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
1068
+ }
1069
+ /* Keep content except for bad-listed elements */
1070
+
1071
+
1072
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1073
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
1074
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
1075
+
1076
+ if (childNodes && parentNode) {
1077
+ const childCount = childNodes.length;
1078
+
1079
+ for (let i = childCount - 1; i >= 0; --i) {
1080
+ parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
1081
+ }
1082
+ }
1083
+ }
1084
+
1085
+ _forceRemove(currentNode);
1086
+
1087
+ return true;
1088
+ }
1089
+ /* Check whether element has a valid namespace */
1090
+
1091
+
1092
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
1093
+ _forceRemove(currentNode);
1094
+
1095
+ return true;
1096
+ }
1097
+ /* Make sure that older browsers don't get noscript mXSS */
1098
+
1099
+
1100
+ if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
1101
+ _forceRemove(currentNode);
1102
+
1103
+ return true;
1104
+ }
1105
+ /* Sanitize element content to be template-safe */
1106
+
1107
+
1108
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
1109
+ /* Get the element's text content */
1110
+ content = currentNode.textContent;
1111
+ content = stringReplace(content, MUSTACHE_EXPR, ' ');
1112
+ content = stringReplace(content, ERB_EXPR, ' ');
1113
+ content = stringReplace(content, TMPLIT_EXPR, ' ');
1114
+
1115
+ if (currentNode.textContent !== content) {
1116
+ arrayPush(DOMPurify.removed, {
1117
+ element: currentNode.cloneNode()
1118
+ });
1119
+ currentNode.textContent = content;
1120
+ }
1121
+ }
1122
+ /* Execute a hook if present */
1123
+
1124
+
1125
+ _executeHook('afterSanitizeElements', currentNode, null);
1126
+
1127
+ return false;
1128
+ };
1129
+ /**
1130
+ * _isValidAttribute
1131
+ *
1132
+ * @param {string} lcTag Lowercase tag name of containing element.
1133
+ * @param {string} lcName Lowercase attribute name.
1134
+ * @param {string} value Attribute value.
1135
+ * @return {Boolean} Returns true if `value` is valid, otherwise false.
1136
+ */
1137
+ // eslint-disable-next-line complexity
1138
+
1139
+
1140
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1141
+ /* Make sure attribute cannot clobber */
1142
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1143
+ return false;
1144
+ }
1145
+ /* Allow valid data-* attributes: At least one character after "-"
1146
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1147
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1148
+ We don't need to check the value; it's always URI safe. */
1149
+
1150
+
1151
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
1152
+ if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1153
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1154
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1155
+ _basicCustomElementTest(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)) || // Alternative, second condition checks if it's an `is`-attribute, AND
1156
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1157
+ 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))) ; else {
1158
+ return false;
1159
+ }
1160
+ /* Check value is safe. First, is attr inert? If so, is safe */
1161
+
1162
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
1163
+ return false;
1164
+ } else ;
1165
+
1166
+ return true;
1167
+ };
1168
+ /**
1169
+ * _basicCustomElementCheck
1170
+ * checks if at least one dash is included in tagName, and it's not the first char
1171
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1172
+ * @param {string} tagName name of the tag of the node to sanitize
1173
+ */
1174
+
1175
+
1176
+ const _basicCustomElementTest = function _basicCustomElementTest(tagName) {
1177
+ return tagName.indexOf('-') > 0;
1178
+ };
1179
+ /**
1180
+ * _sanitizeAttributes
1181
+ *
1182
+ * @protect attributes
1183
+ * @protect nodeName
1184
+ * @protect removeAttribute
1185
+ * @protect setAttribute
1186
+ *
1187
+ * @param {Node} currentNode to sanitize
1188
+ */
1189
+
1190
+
1191
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1192
+ let attr;
1193
+ let value;
1194
+ let lcName;
1195
+ let l;
1196
+ /* Execute a hook if present */
1197
+
1198
+ _executeHook('beforeSanitizeAttributes', currentNode, null);
1199
+
1200
+ const {
1201
+ attributes
1202
+ } = currentNode;
1203
+ /* Check if we have attributes; if not we might have a text node */
1204
+
1205
+ if (!attributes) {
1206
+ return;
1207
+ }
1208
+
1209
+ const hookEvent = {
1210
+ attrName: '',
1211
+ attrValue: '',
1212
+ keepAttr: true,
1213
+ allowedAttributes: ALLOWED_ATTR
1214
+ };
1215
+ l = attributes.length;
1216
+ /* Go backwards over all attributes; safely remove bad ones */
1217
+
1218
+ while (l--) {
1219
+ attr = attributes[l];
1220
+ const {
1221
+ name,
1222
+ namespaceURI
1223
+ } = attr;
1224
+ value = name === 'value' ? attr.value : stringTrim(attr.value);
1225
+ lcName = transformCaseFunc(name);
1226
+ /* Execute a hook if present */
1227
+
1228
+ hookEvent.attrName = lcName;
1229
+ hookEvent.attrValue = value;
1230
+ hookEvent.keepAttr = true;
1231
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1232
+
1233
+ _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1234
+
1235
+ value = hookEvent.attrValue;
1236
+ /* Did the hooks approve of the attribute? */
1237
+
1238
+ if (hookEvent.forceKeepAttr) {
1239
+ continue;
1240
+ }
1241
+ /* Remove attribute */
1242
+
1243
+
1244
+ _removeAttribute(name, currentNode);
1245
+ /* Did the hooks approve of the attribute? */
1246
+
1247
+
1248
+ if (!hookEvent.keepAttr) {
1249
+ continue;
1250
+ }
1251
+ /* Work around a security issue in jQuery 3.0 */
1252
+
1253
+
1254
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1255
+ _removeAttribute(name, currentNode);
1256
+
1257
+ continue;
1258
+ }
1259
+ /* Sanitize attribute content to be template-safe */
1260
+
1261
+
1262
+ if (SAFE_FOR_TEMPLATES) {
1263
+ value = stringReplace(value, MUSTACHE_EXPR, ' ');
1264
+ value = stringReplace(value, ERB_EXPR, ' ');
1265
+ value = stringReplace(value, TMPLIT_EXPR, ' ');
1266
+ }
1267
+ /* Is `value` valid for this attribute? */
1268
+
1269
+
1270
+ const lcTag = transformCaseFunc(currentNode.nodeName);
1271
+
1272
+ if (!_isValidAttribute(lcTag, lcName, value)) {
1273
+ continue;
1274
+ }
1275
+ /* Full DOM Clobbering protection via namespace isolation,
1276
+ * Prefix id and name attributes with `user-content-`
1277
+ */
1278
+
1279
+
1280
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
1281
+ // Remove the attribute with this value
1282
+ _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value
1283
+
1284
+
1285
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
1286
+ }
1287
+ /* Handle attributes that require Trusted Types */
1288
+
1289
+
1290
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1291
+ if (namespaceURI) ; else {
1292
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1293
+ case 'TrustedHTML':
1294
+ {
1295
+ value = trustedTypesPolicy.createHTML(value);
1296
+ break;
1297
+ }
1298
+
1299
+ case 'TrustedScriptURL':
1300
+ {
1301
+ value = trustedTypesPolicy.createScriptURL(value);
1302
+ break;
1303
+ }
1304
+ }
1305
+ }
1306
+ }
1307
+ /* Handle invalid data-* attribute set by try-catching it */
1308
+
1309
+
1310
+ try {
1311
+ if (namespaceURI) {
1312
+ currentNode.setAttributeNS(namespaceURI, name, value);
1313
+ } else {
1314
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1315
+ currentNode.setAttribute(name, value);
1316
+ }
1317
+
1318
+ arrayPop(DOMPurify.removed);
1319
+ } catch (_) {}
1320
+ }
1321
+ /* Execute a hook if present */
1322
+
1323
+
1324
+ _executeHook('afterSanitizeAttributes', currentNode, null);
1325
+ };
1326
+ /**
1327
+ * _sanitizeShadowDOM
1328
+ *
1329
+ * @param {DocumentFragment} fragment to iterate over recursively
1330
+ */
1331
+
1332
+
1333
+ const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
1334
+ let shadowNode;
1335
+
1336
+ const shadowIterator = _createIterator(fragment);
1337
+ /* Execute a hook if present */
1338
+
1339
+
1340
+ _executeHook('beforeSanitizeShadowDOM', fragment, null);
1341
+
1342
+ while (shadowNode = shadowIterator.nextNode()) {
1343
+ /* Execute a hook if present */
1344
+ _executeHook('uponSanitizeShadowNode', shadowNode, null);
1345
+ /* Sanitize tags and elements */
1346
+
1347
+
1348
+ if (_sanitizeElements(shadowNode)) {
1349
+ continue;
1350
+ }
1351
+ /* Deep shadow DOM detected */
1352
+
1353
+
1354
+ if (shadowNode.content instanceof DocumentFragment) {
1355
+ _sanitizeShadowDOM(shadowNode.content);
1356
+ }
1357
+ /* Check attributes, sanitize if necessary */
1358
+
1359
+
1360
+ _sanitizeAttributes(shadowNode);
1361
+ }
1362
+ /* Execute a hook if present */
1363
+
1364
+
1365
+ _executeHook('afterSanitizeShadowDOM', fragment, null);
1366
+ };
1367
+ /**
1368
+ * Sanitize
1369
+ * Public method providing core sanitation functionality
1370
+ *
1371
+ * @param {String|Node} dirty string or DOM node
1372
+ * @param {Object} configuration object
1373
+ */
1374
+ // eslint-disable-next-line complexity
1375
+
1376
+
1377
+ DOMPurify.sanitize = function (dirty) {
1378
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1379
+ let body;
1380
+ let importedNode;
1381
+ let currentNode;
1382
+ let returnNode;
1383
+ /* Make sure we have a string to sanitize.
1384
+ DO NOT return early, as this will return the wrong type if
1385
+ the user has requested a DOM object rather than a string */
1386
+
1387
+ IS_EMPTY_INPUT = !dirty;
1388
+
1389
+ if (IS_EMPTY_INPUT) {
1390
+ dirty = '<!-->';
1391
+ }
1392
+ /* Stringify, in case dirty is an object */
1393
+
1394
+
1395
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
1396
+ if (typeof dirty.toString === 'function') {
1397
+ dirty = dirty.toString();
1398
+
1399
+ if (typeof dirty !== 'string') {
1400
+ throw typeErrorCreate('dirty is not a string, aborting');
1401
+ }
1402
+ } else {
1403
+ throw typeErrorCreate('toString is not a function');
1404
+ }
1405
+ }
1406
+ /* Return dirty HTML if DOMPurify cannot run */
1407
+
1408
+
1409
+ if (!DOMPurify.isSupported) {
1410
+ return dirty;
1411
+ }
1412
+ /* Assign config vars */
1413
+
1414
+
1415
+ if (!SET_CONFIG) {
1416
+ _parseConfig(cfg);
1417
+ }
1418
+ /* Clean up removed elements */
1419
+
1420
+
1421
+ DOMPurify.removed = [];
1422
+ /* Check if dirty is correctly typed for IN_PLACE */
1423
+
1424
+ if (typeof dirty === 'string') {
1425
+ IN_PLACE = false;
1426
+ }
1427
+
1428
+ if (IN_PLACE) {
1429
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
1430
+ if (dirty.nodeName) {
1431
+ const tagName = transformCaseFunc(dirty.nodeName);
1432
+
1433
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1434
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1435
+ }
1436
+ }
1437
+ } else if (dirty instanceof Node) {
1438
+ /* If dirty is a DOM element, append to an empty document to avoid
1439
+ elements being stripped by the parser */
1440
+ body = _initDocument('<!---->');
1441
+ importedNode = body.ownerDocument.importNode(dirty, true);
1442
+
1443
+ if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
1444
+ /* Node is already a body, use as is */
1445
+ body = importedNode;
1446
+ } else if (importedNode.nodeName === 'HTML') {
1447
+ body = importedNode;
1448
+ } else {
1449
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1450
+ body.appendChild(importedNode);
1451
+ }
1452
+ } else {
1453
+ /* Exit directly if we have nothing to do */
1454
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
1455
+ dirty.indexOf('<') === -1) {
1456
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
1457
+ }
1458
+ /* Initialize the document to work on */
1459
+
1460
+
1461
+ body = _initDocument(dirty);
1462
+ /* Check we have a DOM node from the data */
1463
+
1464
+ if (!body) {
1465
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
1466
+ }
1467
+ }
1468
+ /* Remove first element node (ours) if FORCE_BODY is set */
1469
+
1470
+
1471
+ if (body && FORCE_BODY) {
1472
+ _forceRemove(body.firstChild);
1473
+ }
1474
+ /* Get node iterator */
1475
+
1476
+
1477
+ const nodeIterator = _createIterator(IN_PLACE ? dirty : body);
1478
+ /* Now start iterating over the created document */
1479
+
1480
+
1481
+ while (currentNode = nodeIterator.nextNode()) {
1482
+ /* Sanitize tags and elements */
1483
+ if (_sanitizeElements(currentNode)) {
1484
+ continue;
1485
+ }
1486
+ /* Shadow DOM detected, sanitize it */
1487
+
1488
+
1489
+ if (currentNode.content instanceof DocumentFragment) {
1490
+ _sanitizeShadowDOM(currentNode.content);
1491
+ }
1492
+ /* Check attributes, sanitize if necessary */
1493
+
1494
+
1495
+ _sanitizeAttributes(currentNode);
1496
+ }
1497
+ /* If we sanitized `dirty` in-place, return it. */
1498
+
1499
+
1500
+ if (IN_PLACE) {
1501
+ return dirty;
1502
+ }
1503
+ /* Return sanitized string or DOM */
1504
+
1505
+
1506
+ if (RETURN_DOM) {
1507
+ if (RETURN_DOM_FRAGMENT) {
1508
+ returnNode = createDocumentFragment.call(body.ownerDocument);
1509
+
1510
+ while (body.firstChild) {
1511
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1512
+ returnNode.appendChild(body.firstChild);
1513
+ }
1514
+ } else {
1515
+ returnNode = body;
1516
+ }
1517
+
1518
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmod) {
1519
+ /*
1520
+ AdoptNode() is not used because internal state is not reset
1521
+ (e.g. the past names map of a HTMLFormElement), this is safe
1522
+ in theory but we would rather not risk another attack vector.
1523
+ The state that is cloned by importNode() is explicitly defined
1524
+ by the specs.
1525
+ */
1526
+ returnNode = importNode.call(originalDocument, returnNode, true);
1527
+ }
1528
+
1529
+ return returnNode;
1530
+ }
1531
+
1532
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1533
+ /* Serialize doctype if allowed */
1534
+
1535
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1536
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
1537
+ }
1538
+ /* Sanitize final string template-safe */
1539
+
1540
+
1541
+ if (SAFE_FOR_TEMPLATES) {
1542
+ serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR, ' ');
1543
+ serializedHTML = stringReplace(serializedHTML, ERB_EXPR, ' ');
1544
+ serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR, ' ');
1545
+ }
1546
+
1547
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1548
+ };
1549
+ /**
1550
+ * Public method to set the configuration once
1551
+ * setConfig
1552
+ *
1553
+ * @param {Object} cfg configuration object
1554
+ */
1555
+
1556
+
1557
+ DOMPurify.setConfig = function (cfg) {
1558
+ _parseConfig(cfg);
1559
+
1560
+ SET_CONFIG = true;
1561
+ };
1562
+ /**
1563
+ * Public method to remove the configuration
1564
+ * clearConfig
1565
+ *
1566
+ */
1567
+
1568
+
1569
+ DOMPurify.clearConfig = function () {
1570
+ CONFIG = null;
1571
+ SET_CONFIG = false;
1572
+ };
1573
+ /**
1574
+ * Public method to check if an attribute value is valid.
1575
+ * Uses last set config, if any. Otherwise, uses config defaults.
1576
+ * isValidAttribute
1577
+ *
1578
+ * @param {string} tag Tag name of containing element.
1579
+ * @param {string} attr Attribute name.
1580
+ * @param {string} value Attribute value.
1581
+ * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
1582
+ */
1583
+
1584
+
1585
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
1586
+ /* Initialize shared config vars if necessary. */
1587
+ if (!CONFIG) {
1588
+ _parseConfig({});
1589
+ }
1590
+
1591
+ const lcTag = transformCaseFunc(tag);
1592
+ const lcName = transformCaseFunc(attr);
1593
+ return _isValidAttribute(lcTag, lcName, value);
1594
+ };
1595
+ /**
1596
+ * AddHook
1597
+ * Public method to add DOMPurify hooks
1598
+ *
1599
+ * @param {String} entryPoint entry point for the hook to add
1600
+ * @param {Function} hookFunction function to execute
1601
+ */
1602
+
1603
+
1604
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
1605
+ if (typeof hookFunction !== 'function') {
1606
+ return;
1607
+ }
1608
+
1609
+ hooks[entryPoint] = hooks[entryPoint] || [];
1610
+ arrayPush(hooks[entryPoint], hookFunction);
1611
+ };
1612
+ /**
1613
+ * RemoveHook
1614
+ * Public method to remove a DOMPurify hook at a given entryPoint
1615
+ * (pops it from the stack of hooks if more are present)
1616
+ *
1617
+ * @param {String} entryPoint entry point for the hook to remove
1618
+ * @return {Function} removed(popped) hook
1619
+ */
1620
+
1621
+
1622
+ DOMPurify.removeHook = function (entryPoint) {
1623
+ if (hooks[entryPoint]) {
1624
+ return arrayPop(hooks[entryPoint]);
1625
+ }
1626
+ };
1627
+ /**
1628
+ * RemoveHooks
1629
+ * Public method to remove all DOMPurify hooks at a given entryPoint
1630
+ *
1631
+ * @param {String} entryPoint entry point for the hooks to remove
1632
+ */
1633
+
1634
+
1635
+ DOMPurify.removeHooks = function (entryPoint) {
1636
+ if (hooks[entryPoint]) {
1637
+ hooks[entryPoint] = [];
1638
+ }
1639
+ };
1640
+ /**
1641
+ * RemoveAllHooks
1642
+ * Public method to remove all DOMPurify hooks
1643
+ *
1644
+ */
1645
+
1646
+
1647
+ DOMPurify.removeAllHooks = function () {
1648
+ hooks = {};
1649
+ };
1650
+
1651
+ return DOMPurify;
1652
+ }
1653
+
1654
+ var purify = createDOMPurify();
1655
+
33
1656
  var _path$2, _path2$1;
34
1657
  function _extends$2() { return _extends$2 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$2.apply(null, arguments); }
35
1658
  var SvgInternalServerError = function SvgInternalServerError(props) {
@@ -104,6 +1727,7 @@ injectCss.n(css,{});
104
1727
 
105
1728
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
106
1729
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1730
+ var sanitize = purify.sanitize;
107
1731
  var ErrorPage = function ErrorPage(_ref) {
108
1732
  var _ref$homeUrl = _ref.homeUrl,
109
1733
  homeUrl = _ref$homeUrl === void 0 ? "/" : _ref$homeUrl,
@@ -111,7 +1735,8 @@ var ErrorPage = function ErrorPage(_ref) {
111
1735
  backToHomeButtonProps = _ref.backToHomeButtonProps,
112
1736
  children = _ref.children,
113
1737
  _ref$showNeetoChatWid = _ref.showNeetoChatWidget,
114
- showNeetoChatWidget = _ref$showNeetoChatWid === void 0 ? true : _ref$showNeetoChatWid;
1738
+ showNeetoChatWidget = _ref$showNeetoChatWid === void 0 ? true : _ref$showNeetoChatWid,
1739
+ description = _ref.description;
115
1740
  var _useTranslation = reactI18next.useTranslation(),
116
1741
  t = _useTranslation.t;
117
1742
  var _useErrorDisplayStore = useDisplayErrorPage.useErrorDisplayStore(function (store) {
@@ -148,7 +1773,7 @@ var ErrorPage = function ErrorPage(_ref) {
148
1773
  className: "flex min-h-screen w-full flex-col items-center justify-center",
149
1774
  "data-cy": "error-page-container",
150
1775
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
151
- className: "flex flex-col gap-8 p-4 sm:flex-row sm:gap-20 sm:p-6",
1776
+ className: "flex max-w-3xl flex-col gap-8 p-4 sm:flex-row sm:gap-12 sm:p-6",
152
1777
  children: [/*#__PURE__*/jsxRuntime.jsx(Image, {
153
1778
  className: "neeto-molecules-error-code w-full max-w-[150px] sm:max-w-[250px]",
154
1779
  "data-cy": "error-image"
@@ -166,14 +1791,23 @@ var ErrorPage = function ErrorPage(_ref) {
166
1791
  children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
167
1792
  i18nKey: errorKey
168
1793
  })
1794
+ }), !!description && /*#__PURE__*/jsxRuntime.jsx(Typography, {
1795
+ className: "mb-4",
1796
+ dangerouslySetInnerHTML: {
1797
+ __html: sanitize(description)
1798
+ },
1799
+ "data-cy": "description",
1800
+ style: "body1"
169
1801
  }), showNeetoChatWidget && /*#__PURE__*/jsxRuntime.jsx(Typography, {
170
1802
  className: "mb-6",
171
1803
  "data-cy": "title",
172
- style: "body2",
1804
+ style: "body1",
173
1805
  children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
174
1806
  i18nKey: "neetoMolecules.errorPage.contactUs",
175
1807
  components: {
176
1808
  button: /*#__PURE__*/jsxRuntime.jsx(Button, {
1809
+ className: "neeto-ui-font-size-inherit",
1810
+ size: "large",
177
1811
  style: "link",
178
1812
  onClick: openChatWidget
179
1813
  })