@mulmoclaude/core 1.7.1 → 1.8.0

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.
@@ -87,9 +87,2256 @@ function useClipboardCopy(resetMs = DEFAULT_RESET_MS) {
87
87
  };
88
88
  }
89
89
  //#endregion
90
+ //#region ../../node_modules/dompurify/dist/purify.es.mjs
91
+ /*! @license DOMPurify 3.4.12 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.12/LICENSE */
92
+ function _arrayLikeToArray(r, a) {
93
+ (null == a || a > r.length) && (a = r.length);
94
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
95
+ return n;
96
+ }
97
+ function _arrayWithHoles(r) {
98
+ if (Array.isArray(r)) return r;
99
+ }
100
+ function _iterableToArrayLimit(r, l) {
101
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
102
+ if (null != t) {
103
+ var e, n, i, u, a = [], f = true, o = false;
104
+ try {
105
+ if (i = (t = t.call(r)).next, 0 === l);
106
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
107
+ } catch (r) {
108
+ o = true, n = r;
109
+ } finally {
110
+ try {
111
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
112
+ } finally {
113
+ if (o) throw n;
114
+ }
115
+ }
116
+ return a;
117
+ }
118
+ }
119
+ function _nonIterableRest() {
120
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
121
+ }
122
+ function _slicedToArray(r, e) {
123
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
124
+ }
125
+ function _unsupportedIterableToArray(r, a) {
126
+ if (r) {
127
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
128
+ var t = {}.toString.call(r).slice(8, -1);
129
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
130
+ }
131
+ }
132
+ var entries = Object.entries;
133
+ var setPrototypeOf = Object.setPrototypeOf;
134
+ var isFrozen = Object.isFrozen;
135
+ var getPrototypeOf = Object.getPrototypeOf;
136
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
137
+ var freeze = Object.freeze;
138
+ var seal = Object.seal;
139
+ var create = Object.create;
140
+ var _ref = typeof Reflect !== "undefined" && Reflect;
141
+ var apply = _ref.apply;
142
+ var construct = _ref.construct;
143
+ if (!freeze) freeze = function freeze(x) {
144
+ return x;
145
+ };
146
+ if (!seal) seal = function seal(x) {
147
+ return x;
148
+ };
149
+ if (!apply) apply = function apply(func, thisArg) {
150
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
151
+ return func.apply(thisArg, args);
152
+ };
153
+ if (!construct) construct = function construct(Func) {
154
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) args[_key2 - 1] = arguments[_key2];
155
+ return new Func(...args);
156
+ };
157
+ var arrayForEach = unapply(Array.prototype.forEach);
158
+ var arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
159
+ var arrayPop = unapply(Array.prototype.pop);
160
+ var arrayPush = unapply(Array.prototype.push);
161
+ var arraySplice = unapply(Array.prototype.splice);
162
+ var arrayIsArray = Array.isArray;
163
+ var stringToLowerCase = unapply(String.prototype.toLowerCase);
164
+ var stringToString = unapply(String.prototype.toString);
165
+ var stringMatch = unapply(String.prototype.match);
166
+ var stringReplace = unapply(String.prototype.replace);
167
+ var stringIndexOf = unapply(String.prototype.indexOf);
168
+ var stringTrim = unapply(String.prototype.trim);
169
+ var numberToString = unapply(Number.prototype.toString);
170
+ var booleanToString = unapply(Boolean.prototype.toString);
171
+ var bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
172
+ var symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
173
+ var objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
174
+ var objectToString = unapply(Object.prototype.toString);
175
+ var regExpTest = unapply(RegExp.prototype.test);
176
+ var typeErrorCreate = unconstruct(TypeError);
177
+ /**
178
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
179
+ *
180
+ * @param func - The function to be wrapped and called.
181
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
182
+ */
183
+ function unapply(func) {
184
+ return function(thisArg) {
185
+ if (thisArg instanceof RegExp) thisArg.lastIndex = 0;
186
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) args[_key3 - 1] = arguments[_key3];
187
+ return apply(func, thisArg, args);
188
+ };
189
+ }
190
+ /**
191
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
192
+ *
193
+ * @param func - The constructor function to be wrapped and called.
194
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
195
+ */
196
+ function unconstruct(Func) {
197
+ return function() {
198
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) args[_key4] = arguments[_key4];
199
+ return construct(Func, args);
200
+ };
201
+ }
202
+ /**
203
+ * Add properties to a lookup table
204
+ *
205
+ * @param set - The set to which elements will be added.
206
+ * @param array - The array containing elements to be added to the set.
207
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
208
+ * @returns The modified set with added elements.
209
+ */
210
+ function addToSet(set, array) {
211
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
212
+ if (setPrototypeOf) setPrototypeOf(set, null);
213
+ if (!arrayIsArray(array)) return set;
214
+ let l = array.length;
215
+ while (l--) {
216
+ let element = array[l];
217
+ if (typeof element === "string") {
218
+ const lcElement = transformCaseFunc(element);
219
+ if (lcElement !== element) {
220
+ if (!isFrozen(array)) array[l] = lcElement;
221
+ element = lcElement;
222
+ }
223
+ }
224
+ set[element] = true;
225
+ }
226
+ return set;
227
+ }
228
+ /**
229
+ * Clean up an array to harden against CSPP
230
+ *
231
+ * @param array - The array to be cleaned.
232
+ * @returns The cleaned version of the array
233
+ */
234
+ function cleanArray(array) {
235
+ for (let index = 0; index < array.length; index++) if (!objectHasOwnProperty(array, index)) array[index] = null;
236
+ return array;
237
+ }
238
+ /**
239
+ * Shallow clone an object
240
+ *
241
+ * @param object - The object to be cloned.
242
+ * @returns A new object that copies the original.
243
+ */
244
+ function clone(object) {
245
+ const newObject = create(null);
246
+ for (const _ref2 of entries(object)) {
247
+ var _ref3 = _slicedToArray(_ref2, 2);
248
+ const property = _ref3[0];
249
+ const value = _ref3[1];
250
+ if (objectHasOwnProperty(object, property)) if (arrayIsArray(value)) newObject[property] = cleanArray(value);
251
+ else if (value && typeof value === "object" && value.constructor === Object) newObject[property] = clone(value);
252
+ else newObject[property] = value;
253
+ }
254
+ return newObject;
255
+ }
256
+ /**
257
+ * Convert non-node values into strings without depending on direct property access.
258
+ *
259
+ * @param value - The value to stringify.
260
+ * @returns A string representation of the provided value.
261
+ */
262
+ function stringifyValue(value) {
263
+ switch (typeof value) {
264
+ case "string": return value;
265
+ case "number": return numberToString(value);
266
+ case "boolean": return booleanToString(value);
267
+ case "bigint": return bigintToString ? bigintToString(value) : "0";
268
+ case "symbol": return symbolToString ? symbolToString(value) : "Symbol()";
269
+ case "undefined": return objectToString(value);
270
+ case "function":
271
+ case "object": {
272
+ if (value === null) return objectToString(value);
273
+ const valueAsRecord = value;
274
+ const valueToString = lookupGetter(valueAsRecord, "toString");
275
+ if (typeof valueToString === "function") {
276
+ const stringified = valueToString(valueAsRecord);
277
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
278
+ }
279
+ return objectToString(value);
280
+ }
281
+ default: return objectToString(value);
282
+ }
283
+ }
284
+ /**
285
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
286
+ *
287
+ * @param object - The object to look up the getter function in its prototype chain.
288
+ * @param prop - The property name for which to find the getter function.
289
+ * @returns The getter function found in the prototype chain or a fallback function.
290
+ */
291
+ function lookupGetter(object, prop) {
292
+ while (object !== null) {
293
+ const desc = getOwnPropertyDescriptor(object, prop);
294
+ if (desc) {
295
+ if (desc.get) return unapply(desc.get);
296
+ if (typeof desc.value === "function") return unapply(desc.value);
297
+ }
298
+ object = getPrototypeOf(object);
299
+ }
300
+ function fallbackValue() {
301
+ return null;
302
+ }
303
+ return fallbackValue;
304
+ }
305
+ function isRegex(value) {
306
+ try {
307
+ regExpTest(value, "");
308
+ return true;
309
+ } catch (_unused) {
310
+ return false;
311
+ }
312
+ }
313
+ var html$1 = freeze([
314
+ "a",
315
+ "abbr",
316
+ "acronym",
317
+ "address",
318
+ "area",
319
+ "article",
320
+ "aside",
321
+ "audio",
322
+ "b",
323
+ "bdi",
324
+ "bdo",
325
+ "big",
326
+ "blink",
327
+ "blockquote",
328
+ "body",
329
+ "br",
330
+ "button",
331
+ "canvas",
332
+ "caption",
333
+ "center",
334
+ "cite",
335
+ "code",
336
+ "col",
337
+ "colgroup",
338
+ "content",
339
+ "data",
340
+ "datalist",
341
+ "dd",
342
+ "decorator",
343
+ "del",
344
+ "details",
345
+ "dfn",
346
+ "dialog",
347
+ "dir",
348
+ "div",
349
+ "dl",
350
+ "dt",
351
+ "element",
352
+ "em",
353
+ "fieldset",
354
+ "figcaption",
355
+ "figure",
356
+ "font",
357
+ "footer",
358
+ "form",
359
+ "h1",
360
+ "h2",
361
+ "h3",
362
+ "h4",
363
+ "h5",
364
+ "h6",
365
+ "head",
366
+ "header",
367
+ "hgroup",
368
+ "hr",
369
+ "html",
370
+ "i",
371
+ "img",
372
+ "input",
373
+ "ins",
374
+ "kbd",
375
+ "label",
376
+ "legend",
377
+ "li",
378
+ "main",
379
+ "map",
380
+ "mark",
381
+ "marquee",
382
+ "menu",
383
+ "menuitem",
384
+ "meter",
385
+ "nav",
386
+ "nobr",
387
+ "ol",
388
+ "optgroup",
389
+ "option",
390
+ "output",
391
+ "p",
392
+ "picture",
393
+ "pre",
394
+ "progress",
395
+ "q",
396
+ "rp",
397
+ "rt",
398
+ "ruby",
399
+ "s",
400
+ "samp",
401
+ "search",
402
+ "section",
403
+ "select",
404
+ "shadow",
405
+ "slot",
406
+ "small",
407
+ "source",
408
+ "spacer",
409
+ "span",
410
+ "strike",
411
+ "strong",
412
+ "style",
413
+ "sub",
414
+ "summary",
415
+ "sup",
416
+ "table",
417
+ "tbody",
418
+ "td",
419
+ "template",
420
+ "textarea",
421
+ "tfoot",
422
+ "th",
423
+ "thead",
424
+ "time",
425
+ "tr",
426
+ "track",
427
+ "tt",
428
+ "u",
429
+ "ul",
430
+ "var",
431
+ "video",
432
+ "wbr"
433
+ ]);
434
+ var svg$1 = freeze([
435
+ "svg",
436
+ "a",
437
+ "altglyph",
438
+ "altglyphdef",
439
+ "altglyphitem",
440
+ "animatecolor",
441
+ "animatemotion",
442
+ "animatetransform",
443
+ "circle",
444
+ "clippath",
445
+ "defs",
446
+ "desc",
447
+ "ellipse",
448
+ "enterkeyhint",
449
+ "exportparts",
450
+ "filter",
451
+ "font",
452
+ "g",
453
+ "glyph",
454
+ "glyphref",
455
+ "hkern",
456
+ "image",
457
+ "inputmode",
458
+ "line",
459
+ "lineargradient",
460
+ "marker",
461
+ "mask",
462
+ "metadata",
463
+ "mpath",
464
+ "part",
465
+ "path",
466
+ "pattern",
467
+ "polygon",
468
+ "polyline",
469
+ "radialgradient",
470
+ "rect",
471
+ "stop",
472
+ "style",
473
+ "switch",
474
+ "symbol",
475
+ "text",
476
+ "textpath",
477
+ "title",
478
+ "tref",
479
+ "tspan",
480
+ "view",
481
+ "vkern"
482
+ ]);
483
+ var svgFilters = freeze([
484
+ "feBlend",
485
+ "feColorMatrix",
486
+ "feComponentTransfer",
487
+ "feComposite",
488
+ "feConvolveMatrix",
489
+ "feDiffuseLighting",
490
+ "feDisplacementMap",
491
+ "feDistantLight",
492
+ "feDropShadow",
493
+ "feFlood",
494
+ "feFuncA",
495
+ "feFuncB",
496
+ "feFuncG",
497
+ "feFuncR",
498
+ "feGaussianBlur",
499
+ "feImage",
500
+ "feMerge",
501
+ "feMergeNode",
502
+ "feMorphology",
503
+ "feOffset",
504
+ "fePointLight",
505
+ "feSpecularLighting",
506
+ "feSpotLight",
507
+ "feTile",
508
+ "feTurbulence"
509
+ ]);
510
+ var svgDisallowed = freeze([
511
+ "animate",
512
+ "color-profile",
513
+ "cursor",
514
+ "discard",
515
+ "font-face",
516
+ "font-face-format",
517
+ "font-face-name",
518
+ "font-face-src",
519
+ "font-face-uri",
520
+ "foreignobject",
521
+ "hatch",
522
+ "hatchpath",
523
+ "mesh",
524
+ "meshgradient",
525
+ "meshpatch",
526
+ "meshrow",
527
+ "missing-glyph",
528
+ "script",
529
+ "set",
530
+ "solidcolor",
531
+ "unknown",
532
+ "use"
533
+ ]);
534
+ var mathMl$1 = freeze([
535
+ "math",
536
+ "menclose",
537
+ "merror",
538
+ "mfenced",
539
+ "mfrac",
540
+ "mglyph",
541
+ "mi",
542
+ "mlabeledtr",
543
+ "mmultiscripts",
544
+ "mn",
545
+ "mo",
546
+ "mover",
547
+ "mpadded",
548
+ "mphantom",
549
+ "mroot",
550
+ "mrow",
551
+ "ms",
552
+ "mspace",
553
+ "msqrt",
554
+ "mstyle",
555
+ "msub",
556
+ "msup",
557
+ "msubsup",
558
+ "mtable",
559
+ "mtd",
560
+ "mtext",
561
+ "mtr",
562
+ "munder",
563
+ "munderover",
564
+ "mprescripts"
565
+ ]);
566
+ var mathMlDisallowed = freeze([
567
+ "maction",
568
+ "maligngroup",
569
+ "malignmark",
570
+ "mlongdiv",
571
+ "mscarries",
572
+ "mscarry",
573
+ "msgroup",
574
+ "mstack",
575
+ "msline",
576
+ "msrow",
577
+ "semantics",
578
+ "annotation",
579
+ "annotation-xml",
580
+ "mprescripts",
581
+ "none"
582
+ ]);
583
+ var text = freeze(["#text"]);
584
+ var html = freeze([
585
+ "accept",
586
+ "action",
587
+ "align",
588
+ "alt",
589
+ "autocapitalize",
590
+ "autocomplete",
591
+ "autopictureinpicture",
592
+ "autoplay",
593
+ "background",
594
+ "bgcolor",
595
+ "border",
596
+ "capture",
597
+ "cellpadding",
598
+ "cellspacing",
599
+ "checked",
600
+ "cite",
601
+ "class",
602
+ "clear",
603
+ "color",
604
+ "cols",
605
+ "colspan",
606
+ "command",
607
+ "commandfor",
608
+ "controls",
609
+ "controlslist",
610
+ "coords",
611
+ "crossorigin",
612
+ "datetime",
613
+ "decoding",
614
+ "default",
615
+ "dir",
616
+ "disabled",
617
+ "disablepictureinpicture",
618
+ "disableremoteplayback",
619
+ "download",
620
+ "draggable",
621
+ "enctype",
622
+ "enterkeyhint",
623
+ "exportparts",
624
+ "face",
625
+ "for",
626
+ "headers",
627
+ "height",
628
+ "hidden",
629
+ "high",
630
+ "href",
631
+ "hreflang",
632
+ "id",
633
+ "inert",
634
+ "inputmode",
635
+ "integrity",
636
+ "ismap",
637
+ "kind",
638
+ "label",
639
+ "lang",
640
+ "list",
641
+ "loading",
642
+ "loop",
643
+ "low",
644
+ "max",
645
+ "maxlength",
646
+ "media",
647
+ "method",
648
+ "min",
649
+ "minlength",
650
+ "multiple",
651
+ "muted",
652
+ "name",
653
+ "nonce",
654
+ "noshade",
655
+ "novalidate",
656
+ "nowrap",
657
+ "open",
658
+ "optimum",
659
+ "part",
660
+ "pattern",
661
+ "placeholder",
662
+ "playsinline",
663
+ "popover",
664
+ "popovertarget",
665
+ "popovertargetaction",
666
+ "poster",
667
+ "preload",
668
+ "pubdate",
669
+ "radiogroup",
670
+ "readonly",
671
+ "rel",
672
+ "required",
673
+ "rev",
674
+ "reversed",
675
+ "role",
676
+ "rows",
677
+ "rowspan",
678
+ "spellcheck",
679
+ "scope",
680
+ "selected",
681
+ "shape",
682
+ "size",
683
+ "sizes",
684
+ "slot",
685
+ "span",
686
+ "srclang",
687
+ "start",
688
+ "src",
689
+ "srcset",
690
+ "step",
691
+ "style",
692
+ "summary",
693
+ "tabindex",
694
+ "title",
695
+ "translate",
696
+ "type",
697
+ "usemap",
698
+ "valign",
699
+ "value",
700
+ "width",
701
+ "wrap",
702
+ "xmlns"
703
+ ]);
704
+ var svg = freeze([
705
+ "accent-height",
706
+ "accumulate",
707
+ "additive",
708
+ "alignment-baseline",
709
+ "amplitude",
710
+ "ascent",
711
+ "attributename",
712
+ "attributetype",
713
+ "azimuth",
714
+ "basefrequency",
715
+ "baseline-shift",
716
+ "begin",
717
+ "bias",
718
+ "by",
719
+ "class",
720
+ "clip",
721
+ "clippathunits",
722
+ "clip-path",
723
+ "clip-rule",
724
+ "color",
725
+ "color-interpolation",
726
+ "color-interpolation-filters",
727
+ "color-profile",
728
+ "color-rendering",
729
+ "cx",
730
+ "cy",
731
+ "d",
732
+ "dx",
733
+ "dy",
734
+ "diffuseconstant",
735
+ "direction",
736
+ "display",
737
+ "divisor",
738
+ "dominant-baseline",
739
+ "dur",
740
+ "edgemode",
741
+ "elevation",
742
+ "end",
743
+ "exponent",
744
+ "fill",
745
+ "fill-opacity",
746
+ "fill-rule",
747
+ "filter",
748
+ "filterunits",
749
+ "flood-color",
750
+ "flood-opacity",
751
+ "font-family",
752
+ "font-size",
753
+ "font-size-adjust",
754
+ "font-stretch",
755
+ "font-style",
756
+ "font-variant",
757
+ "font-weight",
758
+ "fx",
759
+ "fy",
760
+ "g1",
761
+ "g2",
762
+ "glyph-name",
763
+ "glyphref",
764
+ "gradientunits",
765
+ "gradienttransform",
766
+ "height",
767
+ "href",
768
+ "id",
769
+ "image-rendering",
770
+ "in",
771
+ "in2",
772
+ "intercept",
773
+ "k",
774
+ "k1",
775
+ "k2",
776
+ "k3",
777
+ "k4",
778
+ "kerning",
779
+ "keypoints",
780
+ "keysplines",
781
+ "keytimes",
782
+ "lang",
783
+ "lengthadjust",
784
+ "letter-spacing",
785
+ "kernelmatrix",
786
+ "kernelunitlength",
787
+ "lighting-color",
788
+ "local",
789
+ "marker-end",
790
+ "marker-mid",
791
+ "marker-start",
792
+ "markerheight",
793
+ "markerunits",
794
+ "markerwidth",
795
+ "maskcontentunits",
796
+ "maskunits",
797
+ "max",
798
+ "mask",
799
+ "mask-type",
800
+ "media",
801
+ "method",
802
+ "mode",
803
+ "min",
804
+ "name",
805
+ "numoctaves",
806
+ "offset",
807
+ "operator",
808
+ "opacity",
809
+ "order",
810
+ "orient",
811
+ "orientation",
812
+ "origin",
813
+ "overflow",
814
+ "paint-order",
815
+ "path",
816
+ "pathlength",
817
+ "patterncontentunits",
818
+ "patterntransform",
819
+ "patternunits",
820
+ "points",
821
+ "preservealpha",
822
+ "preserveaspectratio",
823
+ "primitiveunits",
824
+ "r",
825
+ "rx",
826
+ "ry",
827
+ "radius",
828
+ "refx",
829
+ "refy",
830
+ "repeatcount",
831
+ "repeatdur",
832
+ "restart",
833
+ "result",
834
+ "rotate",
835
+ "scale",
836
+ "seed",
837
+ "shape-rendering",
838
+ "slope",
839
+ "specularconstant",
840
+ "specularexponent",
841
+ "spreadmethod",
842
+ "startoffset",
843
+ "stddeviation",
844
+ "stitchtiles",
845
+ "stop-color",
846
+ "stop-opacity",
847
+ "stroke-dasharray",
848
+ "stroke-dashoffset",
849
+ "stroke-linecap",
850
+ "stroke-linejoin",
851
+ "stroke-miterlimit",
852
+ "stroke-opacity",
853
+ "stroke",
854
+ "stroke-width",
855
+ "style",
856
+ "surfacescale",
857
+ "systemlanguage",
858
+ "tabindex",
859
+ "tablevalues",
860
+ "targetx",
861
+ "targety",
862
+ "transform",
863
+ "transform-origin",
864
+ "text-anchor",
865
+ "text-decoration",
866
+ "text-orientation",
867
+ "text-rendering",
868
+ "textlength",
869
+ "type",
870
+ "u1",
871
+ "u2",
872
+ "unicode",
873
+ "values",
874
+ "viewbox",
875
+ "visibility",
876
+ "version",
877
+ "vert-adv-y",
878
+ "vert-origin-x",
879
+ "vert-origin-y",
880
+ "width",
881
+ "word-spacing",
882
+ "wrap",
883
+ "writing-mode",
884
+ "xchannelselector",
885
+ "ychannelselector",
886
+ "x",
887
+ "x1",
888
+ "x2",
889
+ "xmlns",
890
+ "y",
891
+ "y1",
892
+ "y2",
893
+ "z",
894
+ "zoomandpan"
895
+ ]);
896
+ var mathMl = freeze([
897
+ "accent",
898
+ "accentunder",
899
+ "align",
900
+ "bevelled",
901
+ "close",
902
+ "columnalign",
903
+ "columnlines",
904
+ "columnspacing",
905
+ "columnspan",
906
+ "denomalign",
907
+ "depth",
908
+ "dir",
909
+ "display",
910
+ "displaystyle",
911
+ "encoding",
912
+ "fence",
913
+ "frame",
914
+ "height",
915
+ "href",
916
+ "id",
917
+ "largeop",
918
+ "length",
919
+ "linethickness",
920
+ "lquote",
921
+ "lspace",
922
+ "mathbackground",
923
+ "mathcolor",
924
+ "mathsize",
925
+ "mathvariant",
926
+ "maxsize",
927
+ "minsize",
928
+ "movablelimits",
929
+ "notation",
930
+ "numalign",
931
+ "open",
932
+ "rowalign",
933
+ "rowlines",
934
+ "rowspacing",
935
+ "rowspan",
936
+ "rspace",
937
+ "rquote",
938
+ "scriptlevel",
939
+ "scriptminsize",
940
+ "scriptsizemultiplier",
941
+ "selection",
942
+ "separator",
943
+ "separators",
944
+ "stretchy",
945
+ "subscriptshift",
946
+ "supscriptshift",
947
+ "symmetric",
948
+ "voffset",
949
+ "width",
950
+ "xmlns"
951
+ ]);
952
+ var xml = freeze([
953
+ "xlink:href",
954
+ "xml:id",
955
+ "xlink:title",
956
+ "xml:space",
957
+ "xmlns:xlink"
958
+ ]);
959
+ var MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
960
+ var ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
961
+ var TMPLIT_EXPR = seal(/\${[\w\W]*/g);
962
+ var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
963
+ var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
964
+ var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
965
+ var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
966
+ var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
967
+ var DOCTYPE_NAME = seal(/^html$/i);
968
+ var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
969
+ var ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
970
+ var COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
971
+ var FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
972
+ var SELF_CLOSING_TAG = seal(/\/>/i);
973
+ var NODE_TYPE = {
974
+ element: 1,
975
+ attribute: 2,
976
+ text: 3,
977
+ cdataSection: 4,
978
+ entityReference: 5,
979
+ entityNode: 6,
980
+ processingInstruction: 7,
981
+ comment: 8,
982
+ document: 9,
983
+ documentType: 10,
984
+ documentFragment: 11,
985
+ notation: 12
986
+ };
987
+ var getGlobal = function getGlobal() {
988
+ return typeof window === "undefined" ? null : window;
989
+ };
990
+ /**
991
+ * Creates a no-op policy for internal use only.
992
+ * Don't export this function outside this module!
993
+ * @param trustedTypes The policy factory.
994
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
995
+ * @return The policy created (or null, if Trusted Types
996
+ * are not supported or creating the policy failed).
997
+ */
998
+ var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
999
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") return null;
1000
+ let suffix = null;
1001
+ const ATTR_NAME = "data-tt-policy-suffix";
1002
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) suffix = purifyHostElement.getAttribute(ATTR_NAME);
1003
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
1004
+ try {
1005
+ return trustedTypes.createPolicy(policyName, {
1006
+ createHTML(html) {
1007
+ return html;
1008
+ },
1009
+ createScriptURL(scriptUrl) {
1010
+ return scriptUrl;
1011
+ }
1012
+ });
1013
+ } catch (_) {
1014
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
1015
+ return null;
1016
+ }
1017
+ };
1018
+ var _createHooksMap = function _createHooksMap() {
1019
+ return {
1020
+ afterSanitizeAttributes: [],
1021
+ afterSanitizeElements: [],
1022
+ afterSanitizeShadowDOM: [],
1023
+ beforeSanitizeAttributes: [],
1024
+ beforeSanitizeElements: [],
1025
+ beforeSanitizeShadowDOM: [],
1026
+ uponSanitizeAttribute: [],
1027
+ uponSanitizeElement: [],
1028
+ uponSanitizeShadowNode: []
1029
+ };
1030
+ };
1031
+ /**
1032
+ * Resolve a set-valued configuration option: a fresh set built from
1033
+ * cfg[key] when it is an own array property (seeded with a clone of
1034
+ * options.base when given, case-normalized via options.transform),
1035
+ * the fallback set otherwise.
1036
+ *
1037
+ * @param cfg the cloned, prototype-free configuration object
1038
+ * @param key the configuration property to read
1039
+ * @param fallback the set to use when the option is absent or not an array
1040
+ * @param options transform and optional base set to merge into
1041
+ * @returns the resolved set
1042
+ */
1043
+ var _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
1044
+ return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
1045
+ };
1046
+ function createDOMPurify() {
1047
+ let window = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
1048
+ const DOMPurify = (root) => createDOMPurify(root);
1049
+ DOMPurify.version = "3.4.12";
1050
+ DOMPurify.removed = [];
1051
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
1052
+ DOMPurify.isSupported = false;
1053
+ return DOMPurify;
1054
+ }
1055
+ let document = window.document;
1056
+ const originalDocument = document;
1057
+ const currentScript = originalDocument.currentScript;
1058
+ window.DocumentFragment;
1059
+ const HTMLTemplateElement = window.HTMLTemplateElement, Node = window.Node, Element = window.Element, NodeFilter = window.NodeFilter;
1060
+ window.NamedNodeMap === void 0 && (window.NamedNodeMap || window.MozNamedAttrMap);
1061
+ window.HTMLFormElement;
1062
+ const DOMParser = window.DOMParser, trustedTypes = window.trustedTypes;
1063
+ const ElementPrototype = Element.prototype;
1064
+ const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
1065
+ const remove = lookupGetter(ElementPrototype, "remove");
1066
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
1067
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
1068
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
1069
+ const getShadowRoot = lookupGetter(ElementPrototype, "shadowRoot");
1070
+ const getAttributes = lookupGetter(ElementPrototype, "attributes");
1071
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeType") : null;
1072
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeName") : null;
1073
+ if (typeof HTMLTemplateElement === "function") {
1074
+ const template = document.createElement("template");
1075
+ if (template.content && template.content.ownerDocument) document = template.content.ownerDocument;
1076
+ }
1077
+ let trustedTypesPolicy;
1078
+ let emptyHTML = "";
1079
+ let defaultTrustedTypesPolicy;
1080
+ let defaultTrustedTypesPolicyResolved = false;
1081
+ let IN_TRUSTED_TYPES_POLICY = 0;
1082
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
1083
+ if (IN_TRUSTED_TYPES_POLICY > 0) throw typeErrorCreate("A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the \"DOMPurify and Trusted Types\" section of the README.");
1084
+ };
1085
+ const _createTrustedHTML = function _createTrustedHTML(html) {
1086
+ _assertNotInTrustedTypesPolicy();
1087
+ IN_TRUSTED_TYPES_POLICY++;
1088
+ try {
1089
+ return trustedTypesPolicy.createHTML(html);
1090
+ } finally {
1091
+ IN_TRUSTED_TYPES_POLICY--;
1092
+ }
1093
+ };
1094
+ const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
1095
+ _assertNotInTrustedTypesPolicy();
1096
+ IN_TRUSTED_TYPES_POLICY++;
1097
+ try {
1098
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
1099
+ } finally {
1100
+ IN_TRUSTED_TYPES_POLICY--;
1101
+ }
1102
+ };
1103
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
1104
+ if (!defaultTrustedTypesPolicyResolved) {
1105
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1106
+ defaultTrustedTypesPolicyResolved = true;
1107
+ }
1108
+ return defaultTrustedTypesPolicy;
1109
+ };
1110
+ const _document = document, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
1111
+ const importNode = originalDocument.importNode;
1112
+ let hooks = _createHooksMap();
1113
+ /**
1114
+ * Expose whether this browser supports running the full DOMPurify.
1115
+ */
1116
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
1117
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
1118
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
1119
+ /**
1120
+ * We consider the elements and attributes below to be safe. Ideally
1121
+ * don't add any new ones but feel free to remove unwanted ones.
1122
+ */
1123
+ let ALLOWED_TAGS = null;
1124
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [
1125
+ ...html$1,
1126
+ ...svg$1,
1127
+ ...svgFilters,
1128
+ ...mathMl$1,
1129
+ ...text
1130
+ ]);
1131
+ let ALLOWED_ATTR = null;
1132
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [
1133
+ ...html,
1134
+ ...svg,
1135
+ ...mathMl,
1136
+ ...xml
1137
+ ]);
1138
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
1139
+ tagNameCheck: {
1140
+ writable: true,
1141
+ configurable: false,
1142
+ enumerable: true,
1143
+ value: null
1144
+ },
1145
+ attributeNameCheck: {
1146
+ writable: true,
1147
+ configurable: false,
1148
+ enumerable: true,
1149
+ value: null
1150
+ },
1151
+ allowCustomizedBuiltInElements: {
1152
+ writable: true,
1153
+ configurable: false,
1154
+ enumerable: true,
1155
+ value: false
1156
+ }
1157
+ }));
1158
+ let FORBID_TAGS = null;
1159
+ let FORBID_ATTR = null;
1160
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
1161
+ tagCheck: {
1162
+ writable: true,
1163
+ configurable: false,
1164
+ enumerable: true,
1165
+ value: null
1166
+ },
1167
+ attributeCheck: {
1168
+ writable: true,
1169
+ configurable: false,
1170
+ enumerable: true,
1171
+ value: null
1172
+ }
1173
+ }));
1174
+ let ALLOW_ARIA_ATTR = true;
1175
+ let ALLOW_DATA_ATTR = true;
1176
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
1177
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
1178
+ let SAFE_FOR_TEMPLATES = false;
1179
+ let SAFE_FOR_XML = true;
1180
+ let WHOLE_DOCUMENT = false;
1181
+ let SET_CONFIG = false;
1182
+ let SET_CONFIG_ALLOWED_TAGS = null;
1183
+ let SET_CONFIG_ALLOWED_ATTR = null;
1184
+ let FORCE_BODY = false;
1185
+ let RETURN_DOM = false;
1186
+ let RETURN_DOM_FRAGMENT = false;
1187
+ let RETURN_TRUSTED_TYPE = false;
1188
+ let SANITIZE_DOM = true;
1189
+ let SANITIZE_NAMED_PROPS = false;
1190
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
1191
+ let KEEP_CONTENT = true;
1192
+ let IN_PLACE = false;
1193
+ let USE_PROFILES = {};
1194
+ let FORBID_CONTENTS = null;
1195
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, [
1196
+ "annotation-xml",
1197
+ "audio",
1198
+ "colgroup",
1199
+ "desc",
1200
+ "foreignobject",
1201
+ "head",
1202
+ "iframe",
1203
+ "math",
1204
+ "mi",
1205
+ "mn",
1206
+ "mo",
1207
+ "ms",
1208
+ "mtext",
1209
+ "noembed",
1210
+ "noframes",
1211
+ "noscript",
1212
+ "plaintext",
1213
+ "script",
1214
+ "selectedcontent",
1215
+ "style",
1216
+ "svg",
1217
+ "template",
1218
+ "thead",
1219
+ "title",
1220
+ "video",
1221
+ "xmp"
1222
+ ]);
1223
+ let DATA_URI_TAGS = null;
1224
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, [
1225
+ "audio",
1226
+ "video",
1227
+ "img",
1228
+ "source",
1229
+ "image",
1230
+ "track"
1231
+ ]);
1232
+ let URI_SAFE_ATTRIBUTES = null;
1233
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [
1234
+ "alt",
1235
+ "class",
1236
+ "for",
1237
+ "id",
1238
+ "label",
1239
+ "name",
1240
+ "pattern",
1241
+ "placeholder",
1242
+ "role",
1243
+ "summary",
1244
+ "title",
1245
+ "value",
1246
+ "style",
1247
+ "xmlns"
1248
+ ]);
1249
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
1250
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
1251
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
1252
+ let NAMESPACE = HTML_NAMESPACE;
1253
+ let IS_EMPTY_INPUT = false;
1254
+ let ALLOWED_NAMESPACES = null;
1255
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [
1256
+ MATHML_NAMESPACE,
1257
+ SVG_NAMESPACE,
1258
+ HTML_NAMESPACE
1259
+ ], stringToString);
1260
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze([
1261
+ "mi",
1262
+ "mo",
1263
+ "mn",
1264
+ "ms",
1265
+ "mtext"
1266
+ ]);
1267
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
1268
+ const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
1269
+ let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
1270
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [
1271
+ "title",
1272
+ "style",
1273
+ "font",
1274
+ "a",
1275
+ "script"
1276
+ ]);
1277
+ let PARSER_MEDIA_TYPE = null;
1278
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
1279
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
1280
+ let transformCaseFunc = null;
1281
+ let CONFIG = null;
1282
+ const formElement = document.createElement("form");
1283
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
1284
+ return testValue instanceof RegExp || testValue instanceof Function;
1285
+ };
1286
+ /**
1287
+ * _parseConfig
1288
+ *
1289
+ * @param cfg optional config literal
1290
+ */
1291
+ const _parseConfig = function _parseConfig() {
1292
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1293
+ if (CONFIG && CONFIG === cfg) return;
1294
+ if (!cfg || typeof cfg !== "object") cfg = {};
1295
+ cfg = clone(cfg);
1296
+ PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
1297
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
1298
+ ALLOWED_TAGS = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, { transform: transformCaseFunc });
1299
+ ALLOWED_ATTR = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, { transform: transformCaseFunc });
1300
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, { transform: stringToString });
1301
+ URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
1302
+ transform: transformCaseFunc,
1303
+ base: DEFAULT_URI_SAFE_ATTRIBUTES
1304
+ });
1305
+ DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
1306
+ transform: transformCaseFunc,
1307
+ base: DEFAULT_DATA_URI_TAGS
1308
+ });
1309
+ FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, { transform: transformCaseFunc });
1310
+ FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), { transform: transformCaseFunc });
1311
+ FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), { transform: transformCaseFunc });
1312
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
1313
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
1314
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
1315
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
1316
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
1317
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
1318
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
1319
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
1320
+ RETURN_DOM = cfg.RETURN_DOM || false;
1321
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
1322
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
1323
+ FORCE_BODY = cfg.FORCE_BODY || false;
1324
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
1325
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
1326
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
1327
+ IN_PLACE = cfg.IN_PLACE || false;
1328
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
1329
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
1330
+ MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
1331
+ HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
1332
+ const customElementHandling = objectHasOwnProperty(cfg, "CUSTOM_ELEMENT_HANDLING") && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === "object" ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
1333
+ CUSTOM_ELEMENT_HANDLING = create(null);
1334
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
1335
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
1336
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
1337
+ seal(CUSTOM_ELEMENT_HANDLING);
1338
+ if (SAFE_FOR_TEMPLATES) ALLOW_DATA_ATTR = false;
1339
+ if (RETURN_DOM_FRAGMENT) RETURN_DOM = true;
1340
+ if (USE_PROFILES) {
1341
+ ALLOWED_TAGS = addToSet({}, text);
1342
+ ALLOWED_ATTR = create(null);
1343
+ if (USE_PROFILES.html === true) {
1344
+ addToSet(ALLOWED_TAGS, html$1);
1345
+ addToSet(ALLOWED_ATTR, html);
1346
+ }
1347
+ if (USE_PROFILES.svg === true) {
1348
+ addToSet(ALLOWED_TAGS, svg$1);
1349
+ addToSet(ALLOWED_ATTR, svg);
1350
+ addToSet(ALLOWED_ATTR, xml);
1351
+ }
1352
+ if (USE_PROFILES.svgFilters === true) {
1353
+ addToSet(ALLOWED_TAGS, svgFilters);
1354
+ addToSet(ALLOWED_ATTR, svg);
1355
+ addToSet(ALLOWED_ATTR, xml);
1356
+ }
1357
+ if (USE_PROFILES.mathMl === true) {
1358
+ addToSet(ALLOWED_TAGS, mathMl$1);
1359
+ addToSet(ALLOWED_ATTR, mathMl);
1360
+ addToSet(ALLOWED_ATTR, xml);
1361
+ }
1362
+ }
1363
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
1364
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
1365
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
1366
+ if (typeof cfg.ADD_TAGS === "function") EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
1367
+ else if (arrayIsArray(cfg.ADD_TAGS)) {
1368
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) ALLOWED_TAGS = clone(ALLOWED_TAGS);
1369
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
1370
+ }
1371
+ }
1372
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
1373
+ if (typeof cfg.ADD_ATTR === "function") EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
1374
+ else if (arrayIsArray(cfg.ADD_ATTR)) {
1375
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) ALLOWED_ATTR = clone(ALLOWED_ATTR);
1376
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
1377
+ }
1378
+ }
1379
+ if (objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
1380
+ if (objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS)) {
1381
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) FORBID_CONTENTS = clone(FORBID_CONTENTS);
1382
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
1383
+ }
1384
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
1385
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) FORBID_CONTENTS = clone(FORBID_CONTENTS);
1386
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
1387
+ }
1388
+ if (KEEP_CONTENT) ALLOWED_TAGS["#text"] = true;
1389
+ if (WHOLE_DOCUMENT) addToSet(ALLOWED_TAGS, [
1390
+ "html",
1391
+ "head",
1392
+ "body"
1393
+ ]);
1394
+ if (ALLOWED_TAGS.table) {
1395
+ addToSet(ALLOWED_TAGS, ["tbody"]);
1396
+ delete FORBID_TAGS.tbody;
1397
+ }
1398
+ if (cfg.TRUSTED_TYPES_POLICY) {
1399
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.");
1400
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.");
1401
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
1402
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
1403
+ try {
1404
+ emptyHTML = _createTrustedHTML("");
1405
+ } catch (error) {
1406
+ trustedTypesPolicy = previousTrustedTypesPolicy;
1407
+ throw error;
1408
+ }
1409
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
1410
+ trustedTypesPolicy = void 0;
1411
+ emptyHTML = "";
1412
+ } else {
1413
+ if (trustedTypesPolicy === void 0) trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
1414
+ if (trustedTypesPolicy && typeof emptyHTML === "string") emptyHTML = _createTrustedHTML("");
1415
+ }
1416
+ if (freeze) freeze(cfg);
1417
+ CONFIG = cfg;
1418
+ };
1419
+ const ALL_SVG_TAGS = addToSet({}, [
1420
+ ...svg$1,
1421
+ ...svgFilters,
1422
+ ...svgDisallowed
1423
+ ]);
1424
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
1425
+ /**
1426
+ * Namespace rules for an element in the SVG namespace.
1427
+ *
1428
+ * @param tagName the element's lowercase tag name
1429
+ * @param parent the (possibly simulated) parent node
1430
+ * @param parentTagName the parent's lowercase tag name
1431
+ * @returns true if a spec-compliant parser could produce this element
1432
+ */
1433
+ const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
1434
+ if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "svg";
1435
+ if (parent.namespaceURI === MATHML_NAMESPACE) return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1436
+ return Boolean(ALL_SVG_TAGS[tagName]);
1437
+ };
1438
+ /**
1439
+ * Namespace rules for an element in the MathML namespace.
1440
+ *
1441
+ * @param tagName the element's lowercase tag name
1442
+ * @param parent the (possibly simulated) parent node
1443
+ * @param parentTagName the parent's lowercase tag name
1444
+ * @returns true if a spec-compliant parser could produce this element
1445
+ */
1446
+ const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
1447
+ if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "math";
1448
+ if (parent.namespaceURI === SVG_NAMESPACE) return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
1449
+ return Boolean(ALL_MATHML_TAGS[tagName]);
1450
+ };
1451
+ /**
1452
+ * Namespace rules for an element in the HTML namespace.
1453
+ *
1454
+ * @param tagName the element's lowercase tag name
1455
+ * @param parent the (possibly simulated) parent node
1456
+ * @param parentTagName the parent's lowercase tag name
1457
+ * @returns true if a spec-compliant parser could produce this element
1458
+ */
1459
+ const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
1460
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) return false;
1461
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) return false;
1462
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1463
+ };
1464
+ /**
1465
+ * @param element a DOM element whose namespace is being checked
1466
+ * @returns Return false if the element has a
1467
+ * namespace that a spec-compliant parser would never
1468
+ * return. Return true otherwise.
1469
+ */
1470
+ const _checkValidNamespace = function _checkValidNamespace(element) {
1471
+ let parent = getParentNode(element);
1472
+ if (!parent || !parent.tagName) parent = {
1473
+ namespaceURI: NAMESPACE,
1474
+ tagName: "template"
1475
+ };
1476
+ const tagName = stringToLowerCase(element.tagName);
1477
+ const parentTagName = stringToLowerCase(parent.tagName);
1478
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) return false;
1479
+ if (element.namespaceURI === SVG_NAMESPACE) return _checkSvgNamespace(tagName, parent, parentTagName);
1480
+ if (element.namespaceURI === MATHML_NAMESPACE) return _checkMathMlNamespace(tagName, parent, parentTagName);
1481
+ if (element.namespaceURI === HTML_NAMESPACE) return _checkHtmlNamespace(tagName, parent, parentTagName);
1482
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) return true;
1483
+ return false;
1484
+ };
1485
+ /**
1486
+ * _forceRemove
1487
+ *
1488
+ * @param node a DOM node
1489
+ */
1490
+ const _forceRemove = function _forceRemove(node) {
1491
+ arrayPush(DOMPurify.removed, { element: node });
1492
+ try {
1493
+ getParentNode(node).removeChild(node);
1494
+ } catch (_) {
1495
+ remove(node);
1496
+ if (!getParentNode(node)) throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
1497
+ }
1498
+ };
1499
+ /**
1500
+ * _neutralizeRoot
1501
+ *
1502
+ * Fail-closed teardown of an in-place root after the sanitize walk aborts
1503
+ * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
1504
+ * custom element's reaction detaches a node so `_forceRemove`'s deliberate
1505
+ * parentless guard throws, or any other re-entrant engine mutation — would
1506
+ * otherwise leave the caller's *live* tree half-sanitized, with everything
1507
+ * after the abort point still carrying its handlers. There is no safe way
1508
+ * to resume the walk (the tree mutated under us), so we strip the root bare:
1509
+ * remove every child and every attribute, then let the caller's catch see
1510
+ * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
1511
+ * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
1512
+ *
1513
+ * @param root the in-place root to empty
1514
+ */
1515
+ const _neutralizeRoot = function _neutralizeRoot(root) {
1516
+ _neutralizeSubtree(root);
1517
+ const childNodes = getChildNodes(root);
1518
+ if (childNodes) {
1519
+ const snapshot = [];
1520
+ arrayForEach(childNodes, (child) => {
1521
+ arrayPush(snapshot, child);
1522
+ });
1523
+ arrayForEach(snapshot, (child) => {
1524
+ try {
1525
+ remove(child);
1526
+ } catch (_) {}
1527
+ });
1528
+ }
1529
+ const attributes = getAttributes(root);
1530
+ if (attributes) for (let i = attributes.length - 1; i >= 0; --i) {
1531
+ const attribute = attributes[i];
1532
+ const name = attribute && attribute.name;
1533
+ if (typeof name === "string") try {
1534
+ root.removeAttribute(name);
1535
+ } catch (_) {}
1536
+ }
1537
+ };
1538
+ /**
1539
+ * _removeAttribute
1540
+ *
1541
+ * @param name an Attribute name
1542
+ * @param element a DOM node
1543
+ */
1544
+ const _removeAttribute = function _removeAttribute(name, element) {
1545
+ try {
1546
+ arrayPush(DOMPurify.removed, {
1547
+ attribute: element.getAttributeNode(name),
1548
+ from: element
1549
+ });
1550
+ } catch (_) {
1551
+ arrayPush(DOMPurify.removed, {
1552
+ attribute: null,
1553
+ from: element
1554
+ });
1555
+ }
1556
+ element.removeAttribute(name);
1557
+ if (name === "is") if (RETURN_DOM || RETURN_DOM_FRAGMENT) try {
1558
+ _forceRemove(element);
1559
+ } catch (_) {}
1560
+ else try {
1561
+ element.setAttribute(name, "");
1562
+ } catch (_) {}
1563
+ };
1564
+ /**
1565
+ * _stripDisallowedAttributes
1566
+ *
1567
+ * Removes every attribute the active configuration does not allow from a
1568
+ * single element, using the same allowlist as the main attribute pass (so
1569
+ * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
1570
+ * neutralise nodes that are being discarded from an in-place tree.
1571
+ *
1572
+ * @param element the element to strip
1573
+ */
1574
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
1575
+ const attributes = getAttributes(element);
1576
+ if (!attributes) return;
1577
+ for (let i = attributes.length - 1; i >= 0; --i) {
1578
+ const attribute = attributes[i];
1579
+ const name = attribute && attribute.name;
1580
+ if (typeof name !== "string" || ALLOWED_ATTR[transformCaseFunc(name)]) continue;
1581
+ try {
1582
+ element.removeAttribute(name);
1583
+ } catch (_) {}
1584
+ }
1585
+ };
1586
+ /**
1587
+ * _neutralizeSubtree
1588
+ *
1589
+ * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
1590
+ * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
1591
+ * namespace, comment, processing-instruction and KEEP_CONTENT:false removals
1592
+ * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
1593
+ * those dropped nodes are detached from the caller's LIVE tree but a
1594
+ * handler-bearing original among them (an `<img onerror>`/`<video>` that was
1595
+ * loading) keeps its queued resource event, which fires in page scope after
1596
+ * sanitize returns. This walks a removed subtree and strips every attribute
1597
+ * the active configuration does not allow — so `on*` handlers are cancelled
1598
+ * through the SAME allowlist that governs kept nodes, not a separate `/^on/`
1599
+ * blocklist. Run synchronously before sanitize returns, i.e. before any
1600
+ * queued event can fire. Hook-free by design: these nodes leave the output,
1601
+ * so firing attribute hooks for them would be surprising. Clobber-safe reads;
1602
+ * a doomed clobbered node may shadow `removeAttribute` (its own attributes are
1603
+ * irrelevant — it is discarded — while its non-clobbered descendants, e.g.
1604
+ * the `<img>`, are reached and scrubbed).
1605
+ *
1606
+ * @param root the root of a removed subtree to neutralise
1607
+ */
1608
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
1609
+ const stack = [root];
1610
+ while (stack.length > 0) {
1611
+ const node = stack.pop();
1612
+ if ((getNodeType ? getNodeType(node) : node.nodeType) === NODE_TYPE.element) _stripDisallowedAttributes(node);
1613
+ const childNodes = getChildNodes(node);
1614
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
1615
+ }
1616
+ };
1617
+ /**
1618
+ * _neutralizePatchLinkage
1619
+ *
1620
+ * IN_PLACE entry pre-pass (declarative-partial-updates / streaming
1621
+ * hardening, https://github.com/WICG/declarative-partial-updates).
1622
+ *
1623
+ * The main walk strips patch linkage (`for`/`patchsrc`) and removes range
1624
+ * markers (PIs / markup comments) node-by-node, in document order, AS it
1625
+ * reaches each node. On a live in-place root that leaves a window: from the
1626
+ * moment the root is connected until the walk arrives at a given node, that
1627
+ * node's linkage is live. A patch applied on connection/stream can fire as
1628
+ * a microtask during the walk and inject or teleport an unsanitized DOM
1629
+ * range into a region the iterator has already passed and will not revisit,
1630
+ * so the post-return "tree is sanitized" contract is violated. Sweep the
1631
+ * whole tree once up front and sever every linkage before the walk begins,
1632
+ * closing that window.
1633
+ *
1634
+ * This CANNOT undo a patch that already fired before sanitize ran — that is
1635
+ * the irreducible "do not IN_PLACE a live-connected attacker tree" caveat —
1636
+ * but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML
1637
+ * to group with the rest of the declarative-partial-updates handling and
1638
+ * stay overridable, consistent with the codebase.
1639
+ *
1640
+ * Clobber-safe traversal (cached childNodes getter); per-node try/catch so a
1641
+ * clobbered root cannot defeat the sweep of its non-clobbered descendants.
1642
+ *
1643
+ * NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe
1644
+ * .html Q1): this mirrors the existing policy of keeping `for` on
1645
+ * <label>/<output>. If the shipping feature can drive a patch through a
1646
+ * surviving `for`-on-label/output + `id` pair, this pre-pass and the
1647
+ * attribute check at _isBasicCustomElement's caller must additionally drop
1648
+ * that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.
1649
+ *
1650
+ * @param root the in-place root to sweep
1651
+ */
1652
+ const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
1653
+ if (!SAFE_FOR_XML) return;
1654
+ const stack = [root];
1655
+ while (stack.length > 0) {
1656
+ const node = stack.pop();
1657
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
1658
+ if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
1659
+ try {
1660
+ remove(node);
1661
+ } catch (_) {}
1662
+ continue;
1663
+ }
1664
+ if (nodeType === NODE_TYPE.element) {
1665
+ const element = node;
1666
+ const lcTag = transformCaseFunc(getNodeName ? getNodeName(node) : node.nodeName);
1667
+ try {
1668
+ if (element.hasAttribute && element.hasAttribute("patchsrc")) element.removeAttribute("patchsrc");
1669
+ if (element.hasAttribute && element.hasAttribute("for") && lcTag !== "label" && lcTag !== "output") element.removeAttribute("for");
1670
+ } catch (_) {}
1671
+ }
1672
+ const childNodes = getChildNodes(node);
1673
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
1674
+ }
1675
+ };
1676
+ /**
1677
+ * _initDocument
1678
+ *
1679
+ * @param dirty - a string of dirty markup
1680
+ * @return a DOM, filled with the dirty markup
1681
+ */
1682
+ const _initDocument = function _initDocument(dirty) {
1683
+ let doc = null;
1684
+ let leadingWhitespace = null;
1685
+ if (FORCE_BODY) dirty = "<remove></remove>" + dirty;
1686
+ else {
1687
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
1688
+ leadingWhitespace = matches && matches[0];
1689
+ }
1690
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) dirty = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>" + dirty + "</body></html>";
1691
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
1692
+ if (NAMESPACE === HTML_NAMESPACE) try {
1693
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
1694
+ } catch (_) {}
1695
+ if (!doc || !doc.documentElement) {
1696
+ doc = implementation.createDocument(NAMESPACE, "template", null);
1697
+ try {
1698
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
1699
+ } catch (_) {}
1700
+ }
1701
+ const body = doc.body || doc.documentElement;
1702
+ if (dirty && leadingWhitespace) body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1703
+ if (NAMESPACE === HTML_NAMESPACE) return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
1704
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
1705
+ };
1706
+ /**
1707
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
1708
+ *
1709
+ * @param root The root element or node to start traversing on.
1710
+ * @return The created NodeIterator
1711
+ */
1712
+ const _createNodeIterator = function _createNodeIterator(root) {
1713
+ return createNodeIterator.call(root.ownerDocument || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
1714
+ };
1715
+ /**
1716
+ * Replace template expression syntax (mustache, ERB, template
1717
+ * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
1718
+ * sites. Order matters: mustache, then ERB, then template literal.
1719
+ *
1720
+ * @param value the string to scrub
1721
+ * @returns the scrubbed string
1722
+ */
1723
+ const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
1724
+ value = stringReplace(value, MUSTACHE_EXPR$1, " ");
1725
+ value = stringReplace(value, ERB_EXPR$1, " ");
1726
+ value = stringReplace(value, TMPLIT_EXPR$1, " ");
1727
+ return value;
1728
+ };
1729
+ /**
1730
+ * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
1731
+ * character data of an element subtree. Used as the final safety net for
1732
+ * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
1733
+ * which only form after text-node normalization (e.g. fragments split across
1734
+ * stripped elements) cannot survive into a template-evaluating framework.
1735
+ *
1736
+ * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
1737
+ * in place rather than round-tripping through innerHTML. This preserves
1738
+ * descendant node references (important for IN_PLACE callers), avoids a
1739
+ * serialize/reparse cycle, and reads literal character data — which means
1740
+ * `<%...%>` in text content matches the ERB regex against its real bytes
1741
+ * instead of the HTML-entity-escaped form innerHTML would produce.
1742
+ *
1743
+ * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
1744
+ * attributes is performed during the per-node `_sanitizeAttributes` pass.
1745
+ *
1746
+ * @param node The root element whose character data should be scrubbed.
1747
+ */
1748
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
1749
+ var _node$querySelectorAl;
1750
+ node.normalize();
1751
+ const walker = createNodeIterator.call(node.ownerDocument || node, node, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
1752
+ let currentNode = walker.nextNode();
1753
+ while (currentNode) {
1754
+ currentNode.data = _stripTemplateExpressions(currentNode.data);
1755
+ currentNode = walker.nextNode();
1756
+ }
1757
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
1758
+ if (templates) arrayForEach(templates, (tmpl) => {
1759
+ if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
1760
+ });
1761
+ };
1762
+ /**
1763
+ * _isClobbered
1764
+ *
1765
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
1766
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
1767
+ * `name` attribute matching a prototype property shadows that property
1768
+ * on direct reads. We use this check at the IN_PLACE entry-point and
1769
+ * during attribute sanitization to refuse clobbered forms.
1770
+ *
1771
+ * @param element element to check for clobbering attacks
1772
+ * @return true if clobbered, false if safe
1773
+ */
1774
+ const _isClobbered = function _isClobbered(element) {
1775
+ const realTagName = getNodeName ? getNodeName(element) : null;
1776
+ if (typeof realTagName !== "string") return false;
1777
+ if (transformCaseFunc(realTagName) !== "form") return false;
1778
+ return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
1779
+ };
1780
+ /**
1781
+ * Checks whether the given value is a DocumentFragment from any realm.
1782
+ *
1783
+ * The realm-independent replacement reads `nodeType` through the cached
1784
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
1785
+ * constant (11). nodeType is a numeric value resolved from the node's
1786
+ * internal slot, identical across realms for the same kind of node.
1787
+ *
1788
+ * @param value object to check
1789
+ * @return true if value is a DocumentFragment-shaped node from any realm
1790
+ */
1791
+ const _isDocumentFragment = function _isDocumentFragment(value) {
1792
+ if (!getNodeType || typeof value !== "object" || value === null) return false;
1793
+ try {
1794
+ return getNodeType(value) === NODE_TYPE.documentFragment;
1795
+ } catch (_) {
1796
+ return false;
1797
+ }
1798
+ };
1799
+ /**
1800
+ * Checks whether the given object is a DOM node, including nodes that
1801
+ * originate from a different window/realm (e.g. an iframe's
1802
+ * contentDocument). The previous `value instanceof Node` check was
1803
+ * realm-bound: nodes from a different window failed it, causing
1804
+ * sanitize() to silently stringify them and reset IN_PLACE to false,
1805
+ * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
1806
+ *
1807
+ * @param value object to check whether it's a DOM node
1808
+ * @return true if value is a DOM node from any realm
1809
+ */
1810
+ const _isNode = function _isNode(value) {
1811
+ if (!getNodeType || typeof value !== "object" || value === null) return false;
1812
+ try {
1813
+ return typeof getNodeType(value) === "number";
1814
+ } catch (_) {
1815
+ return false;
1816
+ }
1817
+ };
1818
+ function _executeHooks(hooks, currentNode, data) {
1819
+ if (hooks.length === 0) return;
1820
+ arrayForEach(hooks, (hook) => {
1821
+ hook.call(DOMPurify, currentNode, data, CONFIG);
1822
+ });
1823
+ }
1824
+ /**
1825
+ * Structural-threat checks that condemn a node regardless of the
1826
+ * allowlists: mXSS via namespace confusion, risky CSS construction,
1827
+ * processing instructions, markup-bearing comments. Pure predicate;
1828
+ * the caller removes. Check order is load-bearing.
1829
+ *
1830
+ * @param currentNode the node to inspect
1831
+ * @param tagName the node's transformCaseFunc'd tag name
1832
+ * @return true if the node must be removed
1833
+ */
1834
+ const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
1835
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
1836
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) return true;
1837
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
1838
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
1839
+ return false;
1840
+ };
1841
+ /**
1842
+ * Handle a node whose tag is forbidden or not allowlisted: keep
1843
+ * allowed custom elements (false return exits _sanitizeElements
1844
+ * early - the namespace and fallback-tag removal checks are
1845
+ * intentionally skipped for kept custom elements), else hoist
1846
+ * content per KEEP_CONTENT and remove.
1847
+ *
1848
+ * A kept custom element is the ONLY case in which this function
1849
+ * returns false, so the caller uses that return value to run the
1850
+ * afterSanitizeElements hook on the kept element and keep the
1851
+ * element-hook lifecycle consistent with normal allowlisted
1852
+ * elements (GHSA-c2j3-45gr-mqc4).
1853
+ *
1854
+ * @param currentNode the disallowed node
1855
+ * @param tagName the node's transformCaseFunc'd tag name
1856
+ * @return true if the node was removed, false if kept
1857
+ */
1858
+ const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName) {
1859
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
1860
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
1861
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
1862
+ }
1863
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1864
+ const parentNode = getParentNode(currentNode);
1865
+ const childNodes = getChildNodes(currentNode);
1866
+ if (childNodes && parentNode) {
1867
+ const childCount = childNodes.length;
1868
+ for (let i = childCount - 1; i >= 0; --i) {
1869
+ const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
1870
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
1871
+ }
1872
+ }
1873
+ }
1874
+ _forceRemove(currentNode);
1875
+ return true;
1876
+ };
1877
+ /**
1878
+ * _sanitizeElements
1879
+ *
1880
+ * @protect nodeName
1881
+ * @protect textContent
1882
+ * @protect removeChild
1883
+ * @param currentNode to check for permission to exist
1884
+ * @return true if node was killed, false if left alive
1885
+ */
1886
+ const _sanitizeElements = function _sanitizeElements(currentNode, root) {
1887
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
1888
+ if (currentNode !== root && getParentNode(currentNode) === null) return true;
1889
+ if (_isClobbered(currentNode)) {
1890
+ _forceRemove(currentNode);
1891
+ return true;
1892
+ }
1893
+ const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
1894
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
1895
+ tagName,
1896
+ allowedTags: ALLOWED_TAGS
1897
+ });
1898
+ if (currentNode !== root && getParentNode(currentNode) === null) return true;
1899
+ if (_isUnsafeNode(currentNode, tagName)) {
1900
+ _forceRemove(currentNode);
1901
+ return true;
1902
+ }
1903
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
1904
+ const removed = _sanitizeDisallowedNode(currentNode, tagName);
1905
+ if (removed === false) _executeHooks(hooks.afterSanitizeElements, currentNode, null);
1906
+ return removed;
1907
+ }
1908
+ if ((getNodeType ? getNodeType(currentNode) : currentNode.nodeType) === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
1909
+ _forceRemove(currentNode);
1910
+ return true;
1911
+ }
1912
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
1913
+ _forceRemove(currentNode);
1914
+ return true;
1915
+ }
1916
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
1917
+ const content = _stripTemplateExpressions(currentNode.textContent);
1918
+ if (currentNode.textContent !== content) {
1919
+ arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
1920
+ currentNode.textContent = content;
1921
+ }
1922
+ }
1923
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
1924
+ return false;
1925
+ };
1926
+ /**
1927
+ * _isValidAttribute
1928
+ *
1929
+ * @param lcTag Lowercase tag name of containing element.
1930
+ * @param lcName Lowercase attribute name.
1931
+ * @param value Attribute value.
1932
+ * @return Returns true if `value` is valid, otherwise false.
1933
+ */
1934
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1935
+ if (FORBID_ATTR[lcName]) return false;
1936
+ if (SAFE_FOR_XML && lcName === "patchsrc") return false;
1937
+ if (SAFE_FOR_XML && lcName === "for" && lcTag !== "label" && lcTag !== "output") return false;
1938
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document || value in formElement)) return false;
1939
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
1940
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName));
1941
+ else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName));
1942
+ else if (!nameIsPermitted) if (_isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || 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)));
1943
+ else return false;
1944
+ else if (URI_SAFE_ATTRIBUTES[lcName]);
1945
+ else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, "")));
1946
+ else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]);
1947
+ else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, "")));
1948
+ else if (value) return false;
1949
+ return true;
1950
+ };
1951
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, [
1952
+ "annotation-xml",
1953
+ "color-profile",
1954
+ "font-face",
1955
+ "font-face-format",
1956
+ "font-face-name",
1957
+ "font-face-src",
1958
+ "font-face-uri",
1959
+ "missing-glyph"
1960
+ ]);
1961
+ /**
1962
+ * _isBasicCustomElement
1963
+ * checks if at least one dash is included in tagName, and it's not the first char
1964
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1965
+ *
1966
+ * @param tagName name of the tag of the node to sanitize
1967
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
1968
+ */
1969
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
1970
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
1971
+ };
1972
+ /**
1973
+ * Wrap an attribute value in the matching Trusted Types object when
1974
+ * the active policy requires it. Namespaced attributes pass through
1975
+ * unchanged (no TT support yet, see
1976
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
1977
+ *
1978
+ * @param lcTag lowercase tag name of the containing element
1979
+ * @param lcName lowercase attribute name
1980
+ * @param namespaceURI the attribute's namespace, if any
1981
+ * @param value the attribute value to wrap
1982
+ * @return the value, wrapped when Trusted Types demand it
1983
+ */
1984
+ const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
1985
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1986
+ case "TrustedHTML": return _createTrustedHTML(value);
1987
+ case "TrustedScriptURL": return _createTrustedScriptURL(value);
1988
+ }
1989
+ return value;
1990
+ };
1991
+ /**
1992
+ * Write a modified attribute value back onto the element. On
1993
+ * success, re-probe for clobbering introduced by the new value and
1994
+ * remove the element when found; otherwise pop the removal entry
1995
+ * recorded by the earlier _removeAttribute (long-standing pairing
1996
+ * with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
1997
+ * failure, remove the attribute instead.
1998
+ *
1999
+ * @param currentNode the element carrying the attribute
2000
+ * @param name the attribute name as present on the element
2001
+ * @param namespaceURI the attribute's namespace, if any
2002
+ * @param value the new attribute value
2003
+ */
2004
+ const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
2005
+ try {
2006
+ if (namespaceURI) currentNode.setAttributeNS(namespaceURI, name, value);
2007
+ else currentNode.setAttribute(name, value);
2008
+ if (_isClobbered(currentNode)) _forceRemove(currentNode);
2009
+ else arrayPop(DOMPurify.removed);
2010
+ } catch (_) {
2011
+ _removeAttribute(name, currentNode);
2012
+ }
2013
+ };
2014
+ /**
2015
+ * _sanitizeAttributes
2016
+ *
2017
+ * @protect attributes
2018
+ * @protect nodeName
2019
+ * @protect removeAttribute
2020
+ * @protect setAttribute
2021
+ *
2022
+ * @param currentNode to sanitize
2023
+ */
2024
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
2025
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
2026
+ const attributes = currentNode.attributes;
2027
+ if (!attributes || _isClobbered(currentNode)) return;
2028
+ const hookEvent = {
2029
+ attrName: "",
2030
+ attrValue: "",
2031
+ keepAttr: true,
2032
+ allowedAttributes: ALLOWED_ATTR,
2033
+ forceKeepAttr: void 0
2034
+ };
2035
+ let l = attributes.length;
2036
+ const lcTag = transformCaseFunc(currentNode.nodeName);
2037
+ while (l--) {
2038
+ const attr = attributes[l];
2039
+ const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
2040
+ const lcName = transformCaseFunc(name);
2041
+ const initValue = attrValue;
2042
+ let value = name === "value" ? initValue : stringTrim(initValue);
2043
+ hookEvent.attrName = lcName;
2044
+ hookEvent.attrValue = value;
2045
+ hookEvent.keepAttr = true;
2046
+ hookEvent.forceKeepAttr = void 0;
2047
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
2048
+ value = hookEvent.attrValue;
2049
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
2050
+ _removeAttribute(name, currentNode);
2051
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
2052
+ }
2053
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
2054
+ _removeAttribute(name, currentNode);
2055
+ continue;
2056
+ }
2057
+ if (lcName === "attributename" && stringMatch(value, "href")) {
2058
+ _removeAttribute(name, currentNode);
2059
+ continue;
2060
+ }
2061
+ if (hookEvent.forceKeepAttr) continue;
2062
+ if (!hookEvent.keepAttr) {
2063
+ _removeAttribute(name, currentNode);
2064
+ continue;
2065
+ }
2066
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
2067
+ _removeAttribute(name, currentNode);
2068
+ continue;
2069
+ }
2070
+ if (SAFE_FOR_TEMPLATES) value = _stripTemplateExpressions(value);
2071
+ if (!_isValidAttribute(lcTag, lcName, value)) {
2072
+ _removeAttribute(name, currentNode);
2073
+ continue;
2074
+ }
2075
+ value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
2076
+ if (value !== initValue) _setAttributeValue(currentNode, name, namespaceURI, value);
2077
+ }
2078
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
2079
+ };
2080
+ /**
2081
+ * _sanitizeShadowDOM
2082
+ *
2083
+ * @param fragment to iterate over recursively
2084
+ */
2085
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
2086
+ let shadowNode = null;
2087
+ const shadowIterator = _createNodeIterator(fragment);
2088
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
2089
+ while (shadowNode = shadowIterator.nextNode()) {
2090
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
2091
+ _sanitizeElements(shadowNode, fragment);
2092
+ _sanitizeAttributes(shadowNode);
2093
+ if (_isDocumentFragment(shadowNode.content)) _sanitizeShadowDOM2(shadowNode.content);
2094
+ if ((getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType) === NODE_TYPE.element) {
2095
+ const innerSr = getShadowRoot(shadowNode);
2096
+ if (_isDocumentFragment(innerSr)) {
2097
+ _sanitizeAttachedShadowRoots(innerSr);
2098
+ _sanitizeShadowDOM2(innerSr);
2099
+ }
2100
+ }
2101
+ }
2102
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
2103
+ };
2104
+ /**
2105
+ * _sanitizeAttachedShadowRoots
2106
+ *
2107
+ * Walks `root` and feeds every attached shadow root we encounter into
2108
+ * the existing _sanitizeShadowDOM pipeline. The default node iterator
2109
+ * does not descend into shadow trees, so nodes inside an attached
2110
+ * shadow root would otherwise be skipped entirely.
2111
+ *
2112
+ * Two real input paths put attached shadow roots in front of us:
2113
+ * 1. IN_PLACE on a DOM node that already has shadow roots attached.
2114
+ * 2. DOM-node input where importNode(dirty, true) deep-clones the
2115
+ * shadow root because it was created with `clonable: true`.
2116
+ *
2117
+ * This pass runs once, up front, so the main iteration loop (and the
2118
+ * existing _sanitizeShadowDOM template-content recursion) stay
2119
+ * untouched — string-input paths are not affected.
2120
+ *
2121
+ * @param root the subtree root to walk for attached shadow roots
2122
+ */
2123
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
2124
+ const stack = [{
2125
+ node: root,
2126
+ shadow: null
2127
+ }];
2128
+ while (stack.length > 0) {
2129
+ const item = stack.pop();
2130
+ if (item.shadow) {
2131
+ _sanitizeShadowDOM2(item.shadow);
2132
+ continue;
2133
+ }
2134
+ const node = item.node;
2135
+ const isElement = (getNodeType ? getNodeType(node) : node.nodeType) === NODE_TYPE.element;
2136
+ const childNodes = getChildNodes(node);
2137
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push({
2138
+ node: childNodes[i],
2139
+ shadow: null
2140
+ });
2141
+ if (isElement) {
2142
+ const rootName = getNodeName ? getNodeName(node) : null;
2143
+ if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
2144
+ const content = node.content;
2145
+ if (_isDocumentFragment(content)) stack.push({
2146
+ node: content,
2147
+ shadow: null
2148
+ });
2149
+ }
2150
+ }
2151
+ if (isElement) {
2152
+ const sr = getShadowRoot(node);
2153
+ if (_isDocumentFragment(sr)) stack.push({
2154
+ node: null,
2155
+ shadow: sr
2156
+ }, {
2157
+ node: sr,
2158
+ shadow: null
2159
+ });
2160
+ }
2161
+ }
2162
+ };
2163
+ DOMPurify.sanitize = function(dirty) {
2164
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2165
+ let body = null;
2166
+ let importedNode = null;
2167
+ let currentNode = null;
2168
+ let returnNode = null;
2169
+ IS_EMPTY_INPUT = !dirty;
2170
+ if (IS_EMPTY_INPUT) dirty = "<!-->";
2171
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
2172
+ dirty = stringifyValue(dirty);
2173
+ if (typeof dirty !== "string") throw typeErrorCreate("dirty is not a string, aborting");
2174
+ }
2175
+ if (!DOMPurify.isSupported) return dirty;
2176
+ if (SET_CONFIG) {
2177
+ ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
2178
+ ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
2179
+ } else _parseConfig(cfg);
2180
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) ALLOWED_TAGS = clone(ALLOWED_TAGS);
2181
+ if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR = clone(ALLOWED_ATTR);
2182
+ DOMPurify.removed = [];
2183
+ const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
2184
+ if (inPlace) {
2185
+ _neutralizePatchLinkage(dirty);
2186
+ const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
2187
+ if (typeof nn === "string") {
2188
+ const tagName = transformCaseFunc(nn);
2189
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
2190
+ _neutralizeRoot(dirty);
2191
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
2192
+ }
2193
+ }
2194
+ if (_isClobbered(dirty)) {
2195
+ _neutralizeRoot(dirty);
2196
+ throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
2197
+ }
2198
+ try {
2199
+ _sanitizeAttachedShadowRoots(dirty);
2200
+ } catch (error) {
2201
+ _neutralizeRoot(dirty);
2202
+ throw error;
2203
+ }
2204
+ } else if (_isNode(dirty)) {
2205
+ body = _initDocument("<!---->");
2206
+ importedNode = body.ownerDocument.importNode(dirty, true);
2207
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;
2208
+ else if (importedNode.nodeName === "HTML") body = importedNode;
2209
+ else body.appendChild(importedNode);
2210
+ _sanitizeAttachedShadowRoots(importedNode);
2211
+ } else {
2212
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
2213
+ body = _initDocument(dirty);
2214
+ if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
2215
+ }
2216
+ if (body && FORCE_BODY) _forceRemove(body.firstChild);
2217
+ const walkRoot = inPlace ? dirty : body;
2218
+ const nodeIterator = _createNodeIterator(walkRoot);
2219
+ try {
2220
+ while (currentNode = nodeIterator.nextNode()) {
2221
+ _sanitizeElements(currentNode, walkRoot);
2222
+ _sanitizeAttributes(currentNode);
2223
+ if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
2224
+ }
2225
+ } catch (error) {
2226
+ if (inPlace) {
2227
+ _neutralizeRoot(dirty);
2228
+ arrayForEach(DOMPurify.removed, (entry) => {
2229
+ if (entry.element) _neutralizeSubtree(entry.element);
2230
+ });
2231
+ }
2232
+ throw error;
2233
+ }
2234
+ if (inPlace) {
2235
+ arrayForEach(DOMPurify.removed, (entry) => {
2236
+ if (entry.element) _neutralizeSubtree(entry.element);
2237
+ });
2238
+ if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
2239
+ return dirty;
2240
+ }
2241
+ if (RETURN_DOM) {
2242
+ if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(body);
2243
+ if (RETURN_DOM_FRAGMENT) {
2244
+ returnNode = createDocumentFragment.call(body.ownerDocument);
2245
+ while (body.firstChild) returnNode.appendChild(body.firstChild);
2246
+ } else returnNode = body;
2247
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) returnNode = importNode.call(originalDocument, returnNode, true);
2248
+ return returnNode;
2249
+ }
2250
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
2251
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
2252
+ if (SAFE_FOR_TEMPLATES) serializedHTML = _stripTemplateExpressions(serializedHTML);
2253
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
2254
+ };
2255
+ DOMPurify.setConfig = function() {
2256
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2257
+ _parseConfig(cfg);
2258
+ SET_CONFIG = true;
2259
+ SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
2260
+ SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
2261
+ };
2262
+ DOMPurify.clearConfig = function() {
2263
+ CONFIG = null;
2264
+ SET_CONFIG = false;
2265
+ SET_CONFIG_ALLOWED_TAGS = null;
2266
+ SET_CONFIG_ALLOWED_ATTR = null;
2267
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
2268
+ emptyHTML = "";
2269
+ };
2270
+ DOMPurify.isValidAttribute = function(tag, attr, value) {
2271
+ if (!CONFIG) _parseConfig({});
2272
+ const lcTag = transformCaseFunc(tag);
2273
+ const lcName = transformCaseFunc(attr);
2274
+ return _isValidAttribute(lcTag, lcName, value);
2275
+ };
2276
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
2277
+ if (typeof hookFunction !== "function") return;
2278
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
2279
+ arrayPush(hooks[entryPoint], hookFunction);
2280
+ };
2281
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
2282
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
2283
+ if (hookFunction !== void 0) {
2284
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
2285
+ return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
2286
+ }
2287
+ return arrayPop(hooks[entryPoint]);
2288
+ };
2289
+ DOMPurify.removeHooks = function(entryPoint) {
2290
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
2291
+ hooks[entryPoint] = [];
2292
+ };
2293
+ DOMPurify.removeAllHooks = function() {
2294
+ hooks = _createHooksMap();
2295
+ };
2296
+ return DOMPurify;
2297
+ }
2298
+ var purify = createDOMPurify();
2299
+ //#endregion
2300
+ //#region src/plugin-vue/sanitizeMarkdownHtml.ts
2301
+ var ALLOWED_IFRAME_SRC = /^https:\/\/www\.youtube-nocookie\.com\/embed\/[A-Za-z0-9_-]{11}$/;
2302
+ var hookInstalled = false;
2303
+ function ensureHook() {
2304
+ if (hookInstalled) return;
2305
+ hookInstalled = true;
2306
+ purify.addHook("uponSanitizeElement", (node, data) => {
2307
+ if (data.tagName !== "iframe") return;
2308
+ const src = node.getAttribute("src") ?? "";
2309
+ if (!ALLOWED_IFRAME_SRC.test(src)) node.parentNode?.removeChild(node);
2310
+ });
2311
+ }
2312
+ var SANITIZE_CONFIG = {
2313
+ ADD_TAGS: ["iframe"],
2314
+ ADD_ATTR: [
2315
+ "allow",
2316
+ "allowfullscreen",
2317
+ "frameborder",
2318
+ "loading",
2319
+ "referrerpolicy"
2320
+ ]
2321
+ };
2322
+ /** Sanitize HTML produced by `marked.parse`. Strips everything DOMPurify would
2323
+ * normally strip; additionally permits the one YouTube-embed iframe shape. */
2324
+ function sanitizeMarkdownHtml(html) {
2325
+ ensureHook();
2326
+ return purify.sanitize(html, SANITIZE_CONFIG);
2327
+ }
2328
+ /** Test seam — undoes the global DOMPurify hook so an isolated test can verify
2329
+ * the no-hook baseline. Production code never calls this. */
2330
+ function _resetSanitizeForTests() {
2331
+ purify.removeAllHooks();
2332
+ hookInstalled = false;
2333
+ }
2334
+ //#endregion
2335
+ exports._resetSanitizeForTests = _resetSanitizeForTests;
90
2336
  exports.buildMarkdownDocView = buildMarkdownDocView;
91
2337
  exports.formatScalarField = formatScalarField;
92
2338
  exports.nextFileVersion = nextFileVersion;
2339
+ exports.sanitizeMarkdownHtml = sanitizeMarkdownHtml;
93
2340
  exports.useClipboardCopy = useClipboardCopy;
94
2341
  exports.useFileVersion = useFileVersion;
95
2342
  exports.useFileWatch = useFileWatch;