thunderous 0.4.1 → 0.4.3

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.
Files changed (3) hide show
  1. package/dist/index.cjs +987 -28
  2. package/dist/index.js +987 -18
  3. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -36,7 +26,7 @@ __export(src_exports, {
36
26
  css: () => css,
37
27
  customElement: () => customElement,
38
28
  derived: () => derived,
39
- html: () => html
29
+ html: () => html2
40
30
  });
41
31
  module.exports = __toCommonJS(src_exports);
42
32
 
@@ -51,9 +41,9 @@ var parseFragment = (htmlStr) => {
51
41
  range.selectNode(document.body);
52
42
  return range.createContextualFragment(htmlStr);
53
43
  };
54
- var setInnerHTML = (element, html2) => {
44
+ var setInnerHTML = (element, html3) => {
55
45
  clearHTML(element);
56
- const fragment = typeof html2 === "string" ? parseFragment(html2) : html2;
46
+ const fragment = typeof html3 === "string" ? parseFragment(html3) : html3;
57
47
  element.append(fragment);
58
48
  };
59
49
 
@@ -142,9 +132,973 @@ var createEffect = (fn) => {
142
132
  subscriber = null;
143
133
  };
144
134
 
135
+ // node_modules/dompurify/dist/purify.es.mjs
136
+ var {
137
+ entries,
138
+ setPrototypeOf,
139
+ isFrozen,
140
+ getPrototypeOf,
141
+ getOwnPropertyDescriptor
142
+ } = Object;
143
+ var {
144
+ freeze,
145
+ seal,
146
+ create
147
+ } = Object;
148
+ var {
149
+ apply,
150
+ construct
151
+ } = typeof Reflect !== "undefined" && Reflect;
152
+ if (!freeze) {
153
+ freeze = function freeze2(x) {
154
+ return x;
155
+ };
156
+ }
157
+ if (!seal) {
158
+ seal = function seal2(x) {
159
+ return x;
160
+ };
161
+ }
162
+ if (!apply) {
163
+ apply = function apply2(fun, thisValue, args) {
164
+ return fun.apply(thisValue, args);
165
+ };
166
+ }
167
+ if (!construct) {
168
+ construct = function construct2(Func, args) {
169
+ return new Func(...args);
170
+ };
171
+ }
172
+ var arrayForEach = unapply(Array.prototype.forEach);
173
+ var arrayPop = unapply(Array.prototype.pop);
174
+ var arrayPush = unapply(Array.prototype.push);
175
+ var stringToLowerCase = unapply(String.prototype.toLowerCase);
176
+ var stringToString = unapply(String.prototype.toString);
177
+ var stringMatch = unapply(String.prototype.match);
178
+ var stringReplace = unapply(String.prototype.replace);
179
+ var stringIndexOf = unapply(String.prototype.indexOf);
180
+ var stringTrim = unapply(String.prototype.trim);
181
+ var objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
182
+ var regExpTest = unapply(RegExp.prototype.test);
183
+ var typeErrorCreate = unconstruct(TypeError);
184
+ function unapply(func) {
185
+ return function(thisArg) {
186
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
187
+ args[_key - 1] = arguments[_key];
188
+ }
189
+ return apply(func, thisArg, args);
190
+ };
191
+ }
192
+ function unconstruct(func) {
193
+ return function() {
194
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
195
+ args[_key2] = arguments[_key2];
196
+ }
197
+ return construct(func, args);
198
+ };
199
+ }
200
+ function addToSet(set, array) {
201
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
202
+ if (setPrototypeOf) {
203
+ setPrototypeOf(set, null);
204
+ }
205
+ let l = array.length;
206
+ while (l--) {
207
+ let element = array[l];
208
+ if (typeof element === "string") {
209
+ const lcElement = transformCaseFunc(element);
210
+ if (lcElement !== element) {
211
+ if (!isFrozen(array)) {
212
+ array[l] = lcElement;
213
+ }
214
+ element = lcElement;
215
+ }
216
+ }
217
+ set[element] = true;
218
+ }
219
+ return set;
220
+ }
221
+ function cleanArray(array) {
222
+ for (let index = 0; index < array.length; index++) {
223
+ const isPropertyExist = objectHasOwnProperty(array, index);
224
+ if (!isPropertyExist) {
225
+ array[index] = null;
226
+ }
227
+ }
228
+ return array;
229
+ }
230
+ function clone(object) {
231
+ const newObject = create(null);
232
+ for (const [property, value] of entries(object)) {
233
+ const isPropertyExist = objectHasOwnProperty(object, property);
234
+ if (isPropertyExist) {
235
+ if (Array.isArray(value)) {
236
+ newObject[property] = cleanArray(value);
237
+ } else if (value && typeof value === "object" && value.constructor === Object) {
238
+ newObject[property] = clone(value);
239
+ } else {
240
+ newObject[property] = value;
241
+ }
242
+ }
243
+ }
244
+ return newObject;
245
+ }
246
+ function lookupGetter(object, prop) {
247
+ while (object !== null) {
248
+ const desc = getOwnPropertyDescriptor(object, prop);
249
+ if (desc) {
250
+ if (desc.get) {
251
+ return unapply(desc.get);
252
+ }
253
+ if (typeof desc.value === "function") {
254
+ return unapply(desc.value);
255
+ }
256
+ }
257
+ object = getPrototypeOf(object);
258
+ }
259
+ function fallbackValue() {
260
+ return null;
261
+ }
262
+ return fallbackValue;
263
+ }
264
+ var 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"]);
265
+ var 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"]);
266
+ var 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"]);
267
+ var 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"]);
268
+ var 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"]);
269
+ var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
270
+ var text = freeze(["#text"]);
271
+ var 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", "popover", "popovertarget", "popovertargetaction", "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", "wrap", "xmlns", "slot"]);
272
+ var 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", "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"]);
273
+ var 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"]);
274
+ var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
275
+ var MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm);
276
+ var ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
277
+ var TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
278
+ var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/);
279
+ var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
280
+ var IS_ALLOWED_URI = seal(
281
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
282
+ // eslint-disable-line no-useless-escape
283
+ );
284
+ var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
285
+ var ATTR_WHITESPACE = seal(
286
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
287
+ // eslint-disable-line no-control-regex
288
+ );
289
+ var DOCTYPE_NAME = seal(/^html$/i);
290
+ var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
291
+ var EXPRESSIONS = /* @__PURE__ */ Object.freeze({
292
+ __proto__: null,
293
+ ARIA_ATTR,
294
+ ATTR_WHITESPACE,
295
+ CUSTOM_ELEMENT,
296
+ DATA_ATTR,
297
+ DOCTYPE_NAME,
298
+ ERB_EXPR,
299
+ IS_ALLOWED_URI,
300
+ IS_SCRIPT_OR_DATA,
301
+ MUSTACHE_EXPR,
302
+ TMPLIT_EXPR
303
+ });
304
+ var NODE_TYPE = {
305
+ element: 1,
306
+ attribute: 2,
307
+ text: 3,
308
+ cdataSection: 4,
309
+ entityReference: 5,
310
+ // Deprecated
311
+ entityNode: 6,
312
+ // Deprecated
313
+ progressingInstruction: 7,
314
+ comment: 8,
315
+ document: 9,
316
+ documentType: 10,
317
+ documentFragment: 11,
318
+ notation: 12
319
+ // Deprecated
320
+ };
321
+ var getGlobal = function getGlobal2() {
322
+ return typeof window === "undefined" ? null : window;
323
+ };
324
+ var _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
325
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
326
+ return null;
327
+ }
328
+ let suffix = null;
329
+ const ATTR_NAME = "data-tt-policy-suffix";
330
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
331
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
332
+ }
333
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
334
+ try {
335
+ return trustedTypes.createPolicy(policyName, {
336
+ createHTML(html3) {
337
+ return html3;
338
+ },
339
+ createScriptURL(scriptUrl) {
340
+ return scriptUrl;
341
+ }
342
+ });
343
+ } catch (_) {
344
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
345
+ return null;
346
+ }
347
+ };
348
+ function createDOMPurify() {
349
+ let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
350
+ const DOMPurify = (root) => createDOMPurify(root);
351
+ DOMPurify.version = "3.2.1";
352
+ DOMPurify.removed = [];
353
+ if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document) {
354
+ DOMPurify.isSupported = false;
355
+ return DOMPurify;
356
+ }
357
+ let {
358
+ document: document2
359
+ } = window2;
360
+ const originalDocument = document2;
361
+ const currentScript = originalDocument.currentScript;
362
+ const {
363
+ DocumentFragment: DocumentFragment2,
364
+ HTMLTemplateElement,
365
+ Node,
366
+ Element: Element2,
367
+ NodeFilter,
368
+ NamedNodeMap = window2.NamedNodeMap || window2.MozNamedAttrMap,
369
+ HTMLFormElement,
370
+ DOMParser,
371
+ trustedTypes
372
+ } = window2;
373
+ const ElementPrototype = Element2.prototype;
374
+ const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
375
+ const remove = lookupGetter(ElementPrototype, "remove");
376
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
377
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
378
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
379
+ if (typeof HTMLTemplateElement === "function") {
380
+ const template = document2.createElement("template");
381
+ if (template.content && template.content.ownerDocument) {
382
+ document2 = template.content.ownerDocument;
383
+ }
384
+ }
385
+ let trustedTypesPolicy;
386
+ let emptyHTML = "";
387
+ const {
388
+ implementation,
389
+ createNodeIterator,
390
+ createDocumentFragment,
391
+ getElementsByTagName
392
+ } = document2;
393
+ const {
394
+ importNode
395
+ } = originalDocument;
396
+ let hooks = {};
397
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
398
+ const {
399
+ MUSTACHE_EXPR: MUSTACHE_EXPR2,
400
+ ERB_EXPR: ERB_EXPR2,
401
+ TMPLIT_EXPR: TMPLIT_EXPR2,
402
+ DATA_ATTR: DATA_ATTR2,
403
+ ARIA_ATTR: ARIA_ATTR2,
404
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA2,
405
+ ATTR_WHITESPACE: ATTR_WHITESPACE2,
406
+ CUSTOM_ELEMENT: CUSTOM_ELEMENT2
407
+ } = EXPRESSIONS;
408
+ let {
409
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
410
+ } = EXPRESSIONS;
411
+ let ALLOWED_TAGS = null;
412
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
413
+ let ALLOWED_ATTR = null;
414
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
415
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
416
+ tagNameCheck: {
417
+ writable: true,
418
+ configurable: false,
419
+ enumerable: true,
420
+ value: null
421
+ },
422
+ attributeNameCheck: {
423
+ writable: true,
424
+ configurable: false,
425
+ enumerable: true,
426
+ value: null
427
+ },
428
+ allowCustomizedBuiltInElements: {
429
+ writable: true,
430
+ configurable: false,
431
+ enumerable: true,
432
+ value: false
433
+ }
434
+ }));
435
+ let FORBID_TAGS = null;
436
+ let FORBID_ATTR = null;
437
+ let ALLOW_ARIA_ATTR = true;
438
+ let ALLOW_DATA_ATTR = true;
439
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
440
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
441
+ let SAFE_FOR_TEMPLATES = false;
442
+ let SAFE_FOR_XML = true;
443
+ let WHOLE_DOCUMENT = false;
444
+ let SET_CONFIG = false;
445
+ let FORCE_BODY = false;
446
+ let RETURN_DOM = false;
447
+ let RETURN_DOM_FRAGMENT = false;
448
+ let RETURN_TRUSTED_TYPE = false;
449
+ let SANITIZE_DOM = true;
450
+ let SANITIZE_NAMED_PROPS = false;
451
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
452
+ let KEEP_CONTENT = true;
453
+ let IN_PLACE = false;
454
+ let USE_PROFILES = {};
455
+ let FORBID_CONTENTS = null;
456
+ 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"]);
457
+ let DATA_URI_TAGS = null;
458
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
459
+ let URI_SAFE_ATTRIBUTES = null;
460
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
461
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
462
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
463
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
464
+ let NAMESPACE = HTML_NAMESPACE;
465
+ let IS_EMPTY_INPUT = false;
466
+ let ALLOWED_NAMESPACES = null;
467
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
468
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
469
+ let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
470
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
471
+ let PARSER_MEDIA_TYPE = null;
472
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
473
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
474
+ let transformCaseFunc = null;
475
+ let CONFIG = null;
476
+ const formElement = document2.createElement("form");
477
+ const isRegexOrFunction = function isRegexOrFunction2(testValue) {
478
+ return testValue instanceof RegExp || testValue instanceof Function;
479
+ };
480
+ const _parseConfig = function _parseConfig2() {
481
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
482
+ if (CONFIG && CONFIG === cfg) {
483
+ return;
484
+ }
485
+ if (!cfg || typeof cfg !== "object") {
486
+ cfg = {};
487
+ }
488
+ cfg = clone(cfg);
489
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
490
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
491
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
492
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
493
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
494
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
495
+ 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;
496
+ 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;
497
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
498
+ FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
499
+ FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
500
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES : false;
501
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
502
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
503
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
504
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
505
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
506
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
507
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
508
+ RETURN_DOM = cfg.RETURN_DOM || false;
509
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
510
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
511
+ FORCE_BODY = cfg.FORCE_BODY || false;
512
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
513
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
514
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
515
+ IN_PLACE = cfg.IN_PLACE || false;
516
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
517
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
518
+ MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
519
+ HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
520
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
521
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
522
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
523
+ }
524
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
525
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
526
+ }
527
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === "boolean") {
528
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
529
+ }
530
+ if (SAFE_FOR_TEMPLATES) {
531
+ ALLOW_DATA_ATTR = false;
532
+ }
533
+ if (RETURN_DOM_FRAGMENT) {
534
+ RETURN_DOM = true;
535
+ }
536
+ if (USE_PROFILES) {
537
+ ALLOWED_TAGS = addToSet({}, text);
538
+ ALLOWED_ATTR = [];
539
+ if (USE_PROFILES.html === true) {
540
+ addToSet(ALLOWED_TAGS, html$1);
541
+ addToSet(ALLOWED_ATTR, html);
542
+ }
543
+ if (USE_PROFILES.svg === true) {
544
+ addToSet(ALLOWED_TAGS, svg$1);
545
+ addToSet(ALLOWED_ATTR, svg);
546
+ addToSet(ALLOWED_ATTR, xml);
547
+ }
548
+ if (USE_PROFILES.svgFilters === true) {
549
+ addToSet(ALLOWED_TAGS, svgFilters);
550
+ addToSet(ALLOWED_ATTR, svg);
551
+ addToSet(ALLOWED_ATTR, xml);
552
+ }
553
+ if (USE_PROFILES.mathMl === true) {
554
+ addToSet(ALLOWED_TAGS, mathMl$1);
555
+ addToSet(ALLOWED_ATTR, mathMl);
556
+ addToSet(ALLOWED_ATTR, xml);
557
+ }
558
+ }
559
+ if (cfg.ADD_TAGS) {
560
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
561
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
562
+ }
563
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
564
+ }
565
+ if (cfg.ADD_ATTR) {
566
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
567
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
568
+ }
569
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
570
+ }
571
+ if (cfg.ADD_URI_SAFE_ATTR) {
572
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
573
+ }
574
+ if (cfg.FORBID_CONTENTS) {
575
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
576
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
577
+ }
578
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
579
+ }
580
+ if (KEEP_CONTENT) {
581
+ ALLOWED_TAGS["#text"] = true;
582
+ }
583
+ if (WHOLE_DOCUMENT) {
584
+ addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
585
+ }
586
+ if (ALLOWED_TAGS.table) {
587
+ addToSet(ALLOWED_TAGS, ["tbody"]);
588
+ delete FORBID_TAGS.tbody;
589
+ }
590
+ if (cfg.TRUSTED_TYPES_POLICY) {
591
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
592
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
593
+ }
594
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
595
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
596
+ }
597
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
598
+ emptyHTML = trustedTypesPolicy.createHTML("");
599
+ } else {
600
+ if (trustedTypesPolicy === void 0) {
601
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
602
+ }
603
+ if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
604
+ emptyHTML = trustedTypesPolicy.createHTML("");
605
+ }
606
+ }
607
+ if (freeze) {
608
+ freeze(cfg);
609
+ }
610
+ CONFIG = cfg;
611
+ };
612
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
613
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
614
+ const _checkValidNamespace = function _checkValidNamespace2(element) {
615
+ let parent = getParentNode(element);
616
+ if (!parent || !parent.tagName) {
617
+ parent = {
618
+ namespaceURI: NAMESPACE,
619
+ tagName: "template"
620
+ };
621
+ }
622
+ const tagName = stringToLowerCase(element.tagName);
623
+ const parentTagName = stringToLowerCase(parent.tagName);
624
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
625
+ return false;
626
+ }
627
+ if (element.namespaceURI === SVG_NAMESPACE) {
628
+ if (parent.namespaceURI === HTML_NAMESPACE) {
629
+ return tagName === "svg";
630
+ }
631
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
632
+ return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
633
+ }
634
+ return Boolean(ALL_SVG_TAGS[tagName]);
635
+ }
636
+ if (element.namespaceURI === MATHML_NAMESPACE) {
637
+ if (parent.namespaceURI === HTML_NAMESPACE) {
638
+ return tagName === "math";
639
+ }
640
+ if (parent.namespaceURI === SVG_NAMESPACE) {
641
+ return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
642
+ }
643
+ return Boolean(ALL_MATHML_TAGS[tagName]);
644
+ }
645
+ if (element.namespaceURI === HTML_NAMESPACE) {
646
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
647
+ return false;
648
+ }
649
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
650
+ return false;
651
+ }
652
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
653
+ }
654
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
655
+ return true;
656
+ }
657
+ return false;
658
+ };
659
+ const _forceRemove = function _forceRemove2(node) {
660
+ arrayPush(DOMPurify.removed, {
661
+ element: node
662
+ });
663
+ try {
664
+ getParentNode(node).removeChild(node);
665
+ } catch (_) {
666
+ remove(node);
667
+ }
668
+ };
669
+ const _removeAttribute = function _removeAttribute2(name, element) {
670
+ try {
671
+ arrayPush(DOMPurify.removed, {
672
+ attribute: element.getAttributeNode(name),
673
+ from: element
674
+ });
675
+ } catch (_) {
676
+ arrayPush(DOMPurify.removed, {
677
+ attribute: null,
678
+ from: element
679
+ });
680
+ }
681
+ element.removeAttribute(name);
682
+ if (name === "is" && !ALLOWED_ATTR[name]) {
683
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
684
+ try {
685
+ _forceRemove(element);
686
+ } catch (_) {
687
+ }
688
+ } else {
689
+ try {
690
+ element.setAttribute(name, "");
691
+ } catch (_) {
692
+ }
693
+ }
694
+ }
695
+ };
696
+ const _initDocument = function _initDocument2(dirty) {
697
+ let doc = null;
698
+ let leadingWhitespace = null;
699
+ if (FORCE_BODY) {
700
+ dirty = "<remove></remove>" + dirty;
701
+ } else {
702
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
703
+ leadingWhitespace = matches && matches[0];
704
+ }
705
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
706
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
707
+ }
708
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
709
+ if (NAMESPACE === HTML_NAMESPACE) {
710
+ try {
711
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
712
+ } catch (_) {
713
+ }
714
+ }
715
+ if (!doc || !doc.documentElement) {
716
+ doc = implementation.createDocument(NAMESPACE, "template", null);
717
+ try {
718
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
719
+ } catch (_) {
720
+ }
721
+ }
722
+ const body = doc.body || doc.documentElement;
723
+ if (dirty && leadingWhitespace) {
724
+ body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
725
+ }
726
+ if (NAMESPACE === HTML_NAMESPACE) {
727
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
728
+ }
729
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
730
+ };
731
+ const _createNodeIterator = function _createNodeIterator2(root) {
732
+ return createNodeIterator.call(
733
+ root.ownerDocument || root,
734
+ root,
735
+ // eslint-disable-next-line no-bitwise
736
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
737
+ null
738
+ );
739
+ };
740
+ const _isClobbered = function _isClobbered2(element) {
741
+ 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");
742
+ };
743
+ const _isNode = function _isNode2(value) {
744
+ return typeof Node === "function" && value instanceof Node;
745
+ };
746
+ function _executeHook(entryPoint, currentNode, data) {
747
+ if (!hooks[entryPoint]) {
748
+ return;
749
+ }
750
+ arrayForEach(hooks[entryPoint], (hook) => {
751
+ hook.call(DOMPurify, currentNode, data, CONFIG);
752
+ });
753
+ }
754
+ const _sanitizeElements = function _sanitizeElements2(currentNode) {
755
+ let content = null;
756
+ _executeHook("beforeSanitizeElements", currentNode, null);
757
+ if (_isClobbered(currentNode)) {
758
+ _forceRemove(currentNode);
759
+ return true;
760
+ }
761
+ const tagName = transformCaseFunc(currentNode.nodeName);
762
+ _executeHook("uponSanitizeElement", currentNode, {
763
+ tagName,
764
+ allowedTags: ALLOWED_TAGS
765
+ });
766
+ if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
767
+ _forceRemove(currentNode);
768
+ return true;
769
+ }
770
+ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
771
+ _forceRemove(currentNode);
772
+ return true;
773
+ }
774
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
775
+ _forceRemove(currentNode);
776
+ return true;
777
+ }
778
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
779
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
780
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
781
+ return false;
782
+ }
783
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
784
+ return false;
785
+ }
786
+ }
787
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
788
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
789
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
790
+ if (childNodes && parentNode) {
791
+ const childCount = childNodes.length;
792
+ for (let i = childCount - 1; i >= 0; --i) {
793
+ const childClone = cloneNode(childNodes[i], true);
794
+ childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
795
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
796
+ }
797
+ }
798
+ }
799
+ _forceRemove(currentNode);
800
+ return true;
801
+ }
802
+ if (currentNode instanceof Element2 && !_checkValidNamespace(currentNode)) {
803
+ _forceRemove(currentNode);
804
+ return true;
805
+ }
806
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
807
+ _forceRemove(currentNode);
808
+ return true;
809
+ }
810
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
811
+ content = currentNode.textContent;
812
+ arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
813
+ content = stringReplace(content, expr, " ");
814
+ });
815
+ if (currentNode.textContent !== content) {
816
+ arrayPush(DOMPurify.removed, {
817
+ element: currentNode.cloneNode()
818
+ });
819
+ currentNode.textContent = content;
820
+ }
821
+ }
822
+ _executeHook("afterSanitizeElements", currentNode, null);
823
+ return false;
824
+ };
825
+ const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
826
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
827
+ return false;
828
+ }
829
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR2, lcName)) ;
830
+ else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR2, lcName)) ;
831
+ else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
832
+ if (
833
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
834
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
835
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
836
+ _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)) || // Alternative, second condition checks if it's an `is`-attribute, AND
837
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
838
+ 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))
839
+ ) ;
840
+ else {
841
+ return false;
842
+ }
843
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
844
+ else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
845
+ else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
846
+ else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA2, stringReplace(value, ATTR_WHITESPACE2, ""))) ;
847
+ else if (value) {
848
+ return false;
849
+ } else ;
850
+ return true;
851
+ };
852
+ const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
853
+ return tagName !== "annotation-xml" && stringMatch(tagName, CUSTOM_ELEMENT2);
854
+ };
855
+ const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
856
+ _executeHook("beforeSanitizeAttributes", currentNode, null);
857
+ const {
858
+ attributes
859
+ } = currentNode;
860
+ if (!attributes) {
861
+ return;
862
+ }
863
+ const hookEvent = {
864
+ attrName: "",
865
+ attrValue: "",
866
+ keepAttr: true,
867
+ allowedAttributes: ALLOWED_ATTR,
868
+ forceKeepAttr: void 0
869
+ };
870
+ let l = attributes.length;
871
+ while (l--) {
872
+ const attr = attributes[l];
873
+ const {
874
+ name,
875
+ namespaceURI,
876
+ value: attrValue
877
+ } = attr;
878
+ const lcName = transformCaseFunc(name);
879
+ let value = name === "value" ? attrValue : stringTrim(attrValue);
880
+ hookEvent.attrName = lcName;
881
+ hookEvent.attrValue = value;
882
+ hookEvent.keepAttr = true;
883
+ hookEvent.forceKeepAttr = void 0;
884
+ _executeHook("uponSanitizeAttribute", currentNode, hookEvent);
885
+ value = hookEvent.attrValue;
886
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name")) {
887
+ _removeAttribute(name, currentNode);
888
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
889
+ }
890
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
891
+ _removeAttribute(name, currentNode);
892
+ continue;
893
+ }
894
+ if (hookEvent.forceKeepAttr) {
895
+ continue;
896
+ }
897
+ _removeAttribute(name, currentNode);
898
+ if (!hookEvent.keepAttr) {
899
+ continue;
900
+ }
901
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
902
+ _removeAttribute(name, currentNode);
903
+ continue;
904
+ }
905
+ if (SAFE_FOR_TEMPLATES) {
906
+ arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
907
+ value = stringReplace(value, expr, " ");
908
+ });
909
+ }
910
+ const lcTag = transformCaseFunc(currentNode.nodeName);
911
+ if (!_isValidAttribute(lcTag, lcName, value)) {
912
+ continue;
913
+ }
914
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
915
+ if (namespaceURI) ;
916
+ else {
917
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
918
+ case "TrustedHTML": {
919
+ value = trustedTypesPolicy.createHTML(value);
920
+ break;
921
+ }
922
+ case "TrustedScriptURL": {
923
+ value = trustedTypesPolicy.createScriptURL(value);
924
+ break;
925
+ }
926
+ }
927
+ }
928
+ }
929
+ try {
930
+ if (namespaceURI) {
931
+ currentNode.setAttributeNS(namespaceURI, name, value);
932
+ } else {
933
+ currentNode.setAttribute(name, value);
934
+ }
935
+ if (_isClobbered(currentNode)) {
936
+ _forceRemove(currentNode);
937
+ } else {
938
+ arrayPop(DOMPurify.removed);
939
+ }
940
+ } catch (_) {
941
+ }
942
+ }
943
+ _executeHook("afterSanitizeAttributes", currentNode, null);
944
+ };
945
+ const _sanitizeShadowDOM = function _sanitizeShadowDOM2(fragment) {
946
+ let shadowNode = null;
947
+ const shadowIterator = _createNodeIterator(fragment);
948
+ _executeHook("beforeSanitizeShadowDOM", fragment, null);
949
+ while (shadowNode = shadowIterator.nextNode()) {
950
+ _executeHook("uponSanitizeShadowNode", shadowNode, null);
951
+ if (_sanitizeElements(shadowNode)) {
952
+ continue;
953
+ }
954
+ if (shadowNode.content instanceof DocumentFragment2) {
955
+ _sanitizeShadowDOM2(shadowNode.content);
956
+ }
957
+ _sanitizeAttributes(shadowNode);
958
+ }
959
+ _executeHook("afterSanitizeShadowDOM", fragment, null);
960
+ };
961
+ DOMPurify.sanitize = function(dirty) {
962
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
963
+ let body = null;
964
+ let importedNode = null;
965
+ let currentNode = null;
966
+ let returnNode = null;
967
+ IS_EMPTY_INPUT = !dirty;
968
+ if (IS_EMPTY_INPUT) {
969
+ dirty = "<!-->";
970
+ }
971
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
972
+ if (typeof dirty.toString === "function") {
973
+ dirty = dirty.toString();
974
+ if (typeof dirty !== "string") {
975
+ throw typeErrorCreate("dirty is not a string, aborting");
976
+ }
977
+ } else {
978
+ throw typeErrorCreate("toString is not a function");
979
+ }
980
+ }
981
+ if (!DOMPurify.isSupported) {
982
+ return dirty;
983
+ }
984
+ if (!SET_CONFIG) {
985
+ _parseConfig(cfg);
986
+ }
987
+ DOMPurify.removed = [];
988
+ if (typeof dirty === "string") {
989
+ IN_PLACE = false;
990
+ }
991
+ if (IN_PLACE) {
992
+ if (dirty.nodeName) {
993
+ const tagName = transformCaseFunc(dirty.nodeName);
994
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
995
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
996
+ }
997
+ }
998
+ } else if (dirty instanceof Node) {
999
+ body = _initDocument("<!---->");
1000
+ importedNode = body.ownerDocument.importNode(dirty, true);
1001
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") {
1002
+ body = importedNode;
1003
+ } else if (importedNode.nodeName === "HTML") {
1004
+ body = importedNode;
1005
+ } else {
1006
+ body.appendChild(importedNode);
1007
+ }
1008
+ } else {
1009
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
1010
+ dirty.indexOf("<") === -1) {
1011
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
1012
+ }
1013
+ body = _initDocument(dirty);
1014
+ if (!body) {
1015
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
1016
+ }
1017
+ }
1018
+ if (body && FORCE_BODY) {
1019
+ _forceRemove(body.firstChild);
1020
+ }
1021
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
1022
+ while (currentNode = nodeIterator.nextNode()) {
1023
+ if (_sanitizeElements(currentNode)) {
1024
+ continue;
1025
+ }
1026
+ if (currentNode.content instanceof DocumentFragment2) {
1027
+ _sanitizeShadowDOM(currentNode.content);
1028
+ }
1029
+ _sanitizeAttributes(currentNode);
1030
+ }
1031
+ if (IN_PLACE) {
1032
+ return dirty;
1033
+ }
1034
+ if (RETURN_DOM) {
1035
+ if (RETURN_DOM_FRAGMENT) {
1036
+ returnNode = createDocumentFragment.call(body.ownerDocument);
1037
+ while (body.firstChild) {
1038
+ returnNode.appendChild(body.firstChild);
1039
+ }
1040
+ } else {
1041
+ returnNode = body;
1042
+ }
1043
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
1044
+ returnNode = importNode.call(originalDocument, returnNode, true);
1045
+ }
1046
+ return returnNode;
1047
+ }
1048
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1049
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1050
+ serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
1051
+ }
1052
+ if (SAFE_FOR_TEMPLATES) {
1053
+ arrayForEach([MUSTACHE_EXPR2, ERB_EXPR2, TMPLIT_EXPR2], (expr) => {
1054
+ serializedHTML = stringReplace(serializedHTML, expr, " ");
1055
+ });
1056
+ }
1057
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1058
+ };
1059
+ DOMPurify.setConfig = function() {
1060
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1061
+ _parseConfig(cfg);
1062
+ SET_CONFIG = true;
1063
+ };
1064
+ DOMPurify.clearConfig = function() {
1065
+ CONFIG = null;
1066
+ SET_CONFIG = false;
1067
+ };
1068
+ DOMPurify.isValidAttribute = function(tag, attr, value) {
1069
+ if (!CONFIG) {
1070
+ _parseConfig({});
1071
+ }
1072
+ const lcTag = transformCaseFunc(tag);
1073
+ const lcName = transformCaseFunc(attr);
1074
+ return _isValidAttribute(lcTag, lcName, value);
1075
+ };
1076
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
1077
+ if (typeof hookFunction !== "function") {
1078
+ return;
1079
+ }
1080
+ hooks[entryPoint] = hooks[entryPoint] || [];
1081
+ arrayPush(hooks[entryPoint], hookFunction);
1082
+ };
1083
+ DOMPurify.removeHook = function(entryPoint) {
1084
+ if (hooks[entryPoint]) {
1085
+ return arrayPop(hooks[entryPoint]);
1086
+ }
1087
+ };
1088
+ DOMPurify.removeHooks = function(entryPoint) {
1089
+ if (hooks[entryPoint]) {
1090
+ hooks[entryPoint] = [];
1091
+ }
1092
+ };
1093
+ DOMPurify.removeAllHooks = function() {
1094
+ hooks = {};
1095
+ };
1096
+ return DOMPurify;
1097
+ }
1098
+ var purify = createDOMPurify();
1099
+
145
1100
  // src/render.ts
146
- var import_dompurify = __toESM(require("dompurify"), 1);
147
- var html = (strings, ...values) => {
1101
+ var html2 = (strings, ...values) => {
148
1102
  let innerHTML = "";
149
1103
  const signalMap = /* @__PURE__ */ new Map();
150
1104
  strings.forEach((string, i) => {
@@ -156,7 +1110,7 @@ var html = (strings, ...values) => {
156
1110
  }
157
1111
  innerHTML += string + String(value);
158
1112
  });
159
- import_dompurify.default.sanitize(innerHTML);
1113
+ purify.sanitize(innerHTML);
160
1114
  const fragment = parseFragment(innerHTML);
161
1115
  const callbackBindingRegex = /(\{\{callback:.+\}\})/;
162
1116
  const signalBindingRegex = /(\{\{signal:.+\}\})/;
@@ -164,10 +1118,10 @@ var html = (strings, ...values) => {
164
1118
  for (const child of element.childNodes) {
165
1119
  if (child instanceof Text && signalBindingRegex.test(child.data)) {
166
1120
  const textList = child.data.split(signalBindingRegex);
167
- textList.forEach((text, i) => {
168
- const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
169
- const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : void 0;
170
- const newValue = signal !== void 0 ? signal() : text;
1121
+ textList.forEach((text2, i) => {
1122
+ const uniqueKey = text2.replace(/\{\{signal:(.+)\}\}/, "$1");
1123
+ const signal = uniqueKey !== text2 ? signalMap.get(uniqueKey) : void 0;
1124
+ const newValue = signal !== void 0 ? signal() : text2;
171
1125
  const newNode = (() => {
172
1126
  if (typeof newValue === "string") return new Text(newValue);
173
1127
  if (newValue instanceof DocumentFragment) return newValue;
@@ -192,10 +1146,10 @@ var html = (strings, ...values) => {
192
1146
  createEffect(() => {
193
1147
  let newText = "";
194
1148
  let hasNull = false;
195
- for (const text of textList) {
196
- const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
197
- const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : void 0;
198
- const value = signal !== void 0 ? signal() : text;
1149
+ for (const text2 of textList) {
1150
+ const uniqueKey = text2.replace(/\{\{signal:(.+)\}\}/, "$1");
1151
+ const signal = uniqueKey !== text2 ? signalMap.get(uniqueKey) : void 0;
1152
+ const value = signal !== void 0 ? signal() : text2;
199
1153
  if (value === null) hasNull = true;
200
1154
  newText += value;
201
1155
  }
@@ -243,10 +1197,10 @@ var css = (strings, ...values) => {
243
1197
  const textList = cssText.split(signalBindingRegex);
244
1198
  createEffect(() => {
245
1199
  const newCSSTextList = [];
246
- for (const text of textList) {
247
- const uniqueKey = text.replace(/\{\{signal:(.+)\}\}/, "$1");
248
- const signal = uniqueKey !== text ? signalMap.get(uniqueKey) : null;
249
- const newText = signal !== null ? signal() : text;
1200
+ for (const text2 of textList) {
1201
+ const uniqueKey = text2.replace(/\{\{signal:(.+)\}\}/, "$1");
1202
+ const signal = uniqueKey !== text2 ? signalMap.get(uniqueKey) : null;
1203
+ const newText = signal !== null ? signal() : text2;
250
1204
  newCSSTextList.push(newText);
251
1205
  }
252
1206
  const newCSSText = newCSSTextList.join("");
@@ -558,3 +1512,8 @@ var createRegistry = () => {
558
1512
  derived,
559
1513
  html
560
1514
  });
1515
+ /*! Bundled license information:
1516
+
1517
+ dompurify/dist/purify.es.mjs:
1518
+ (*! @license DOMPurify 3.2.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.2.1/LICENSE *)
1519
+ */