UNPKG

@anoki/fse-ui

Version:

FSE UI components library

541 lines (540 loc) • 30 kB
/*! @license DOMPurify 3.2.7 | (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.7/LICENSE */ var ve, St; function dn() { if (St) return ve; St = 1; const { entries: ke, setPrototypeOf: Ue, isFrozen: Rt, getPrototypeOf: Ot, getOwnPropertyDescriptor: yt } = Object; let { freeze: g, seal: L, create: Fe } = Object, { apply: ue, construct: me } = typeof Reflect < "u" && Reflect; g || (g = function(o) { return o; }), L || (L = function(o) { return o; }), ue || (ue = function(o, l) { for (var a = arguments.length, c = new Array(a > 2 ? a - 2 : 0), O = 2; O < a; O++) c[O - 2] = arguments[O]; return o.apply(l, c); }), me || (me = function(o) { for (var l = arguments.length, a = new Array(l > 1 ? l - 1 : 0), c = 1; c < l; c++) a[c - 1] = arguments[c]; return new o(...a); }); const Q = A(Array.prototype.forEach), Lt = A(Array.prototype.lastIndexOf), He = A(Array.prototype.pop), W = A(Array.prototype.push), Dt = A(Array.prototype.splice), ee = A(String.prototype.toLowerCase), pe = A(String.prototype.toString), de = A(String.prototype.match), B = A(String.prototype.replace), bt = A(String.prototype.indexOf), Nt = A(String.prototype.trim), D = A(Object.prototype.hasOwnProperty), h = A(RegExp.prototype.test), Y = It(TypeError); function A(s) { return function(o) { o instanceof RegExp && (o.lastIndex = 0); for (var l = arguments.length, a = new Array(l > 1 ? l - 1 : 0), c = 1; c < l; c++) a[c - 1] = arguments[c]; return ue(s, o, a); }; } function It(s) { return function() { for (var o = arguments.length, l = new Array(o), a = 0; a < o; a++) l[a] = arguments[a]; return me(s, l); }; } function r(s, o) { let l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ee; Ue && Ue(s, null); let a = o.length; for (; a--; ) { let c = o[a]; if (typeof c == "string") { const O = l(c); O !== c && (Rt(o) || (o[a] = O), c = O); } s[c] = !0; } return s; } function Mt(s) { for (let o = 0; o < s.length; o++) D(s, o) || (s[o] = null); return s; } function N(s) { const o = Fe(null); for (const [l, a] of ke(s)) D(s, l) && (Array.isArray(a) ? o[l] = Mt(a) : a && typeof a == "object" && a.constructor === Object ? o[l] = N(a) : o[l] = a); return o; } function X(s, o) { for (; s !== null; ) { const a = yt(s, o); if (a) { if (a.get) return A(a.get); if (typeof a.value == "function") return A(a.value); } s = Ot(s); } function l() { return null; } return l; } const ze = g(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Te = g(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "slot", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Ee = g(["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"]), Ct = g(["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"]), _e = g(["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"]), wt = g(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Ge = g(["#text"]), We = g(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), ge = g(["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"]), Be = g(["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"]), te = g(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), xt = L(/\{\{[\w\W]*|[\w\W]*\}\}/gm), Pt = L(/<%[\w\W]*|[\w\W]*%>/gm), vt = L(/\$\{[\w\W]*/gm), kt = L(/^data-[\-\w.\u00B7-\uFFFF]+$/), Ut = L(/^aria-[\-\w]+$/), Ye = L( /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape ), Ft = L(/^(?:\w+script|data):/i), Ht = L( /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex ), Xe = L(/^html$/i), zt = L(/^[a-z][.\w]*(-[.\w]+)+$/i); var je = /* @__PURE__ */ Object.freeze({ __proto__: null, ARIA_ATTR: Ut, ATTR_WHITESPACE: Ht, CUSTOM_ELEMENT: zt, DATA_ATTR: kt, DOCTYPE_NAME: Xe, ERB_EXPR: Pt, IS_ALLOWED_URI: Ye, IS_SCRIPT_OR_DATA: Ft, MUSTACHE_EXPR: xt, TMPLIT_EXPR: vt }); const j = { element: 1, text: 3, // Deprecated progressingInstruction: 7, comment: 8, document: 9 }, Gt = function() { return typeof window > "u" ? null : window; }, Wt = function(o, l) { if (typeof o != "object" || typeof o.createPolicy != "function") return null; let a = null; const c = "data-tt-policy-suffix"; l && l.hasAttribute(c) && (a = l.getAttribute(c)); const O = "dompurify" + (a ? "#" + a : ""); try { return o.createPolicy(O, { createHTML(P) { return P; }, createScriptURL(P) { return P; } }); } catch { return console.warn("TrustedTypes policy " + O + " could not be created."), null; } }, Ve = function() { return { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] }; }; function qe() { let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Gt(); const o = (i) => qe(i); if (o.version = "3.2.7", o.removed = [], !s || !s.document || s.document.nodeType !== j.document || !s.Element) return o.isSupported = !1, o; let { document: l } = s; const a = l, c = a.currentScript, { DocumentFragment: O, HTMLTemplateElement: P, Node: he, Element: $e, NodeFilter: V, NamedNodeMap: Yt = s.NamedNodeMap || s.MozNamedAttrMap, HTMLFormElement: Xt, DOMParser: jt, trustedTypes: ne } = s, q = $e.prototype, Vt = X(q, "cloneNode"), qt = X(q, "remove"), $t = X(q, "nextSibling"), Kt = X(q, "childNodes"), oe = X(q, "parentNode"); if (typeof P == "function") { const i = l.createElement("template"); i.content && i.content.ownerDocument && (l = i.content.ownerDocument); } let S, $ = ""; const { implementation: Ae, createNodeIterator: Zt, createDocumentFragment: Jt, getElementsByTagName: Qt } = l, { importNode: en } = a; let R = Ve(); o.isSupported = typeof ke == "function" && typeof oe == "function" && Ae && Ae.createHTMLDocument !== void 0; const { MUSTACHE_EXPR: Se, ERB_EXPR: Re, TMPLIT_EXPR: Oe, DATA_ATTR: tn, ARIA_ATTR: nn, IS_SCRIPT_OR_DATA: on, ATTR_WHITESPACE: Ke, CUSTOM_ELEMENT: an } = je; let { IS_ALLOWED_URI: Ze } = je, p = null; const Je = r({}, [...ze, ...Te, ...Ee, ..._e, ...Ge]); let T = null; const Qe = r({}, [...We, ...ge, ...Be, ...te]); let u = Object.seal(Fe(null, { tagNameCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, attributeNameCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, allowCustomizedBuiltInElements: { writable: !0, configurable: !1, enumerable: !0, value: !1 } })), K = null, ye = null, et = !0, Le = !0, tt = !1, nt = !0, v = !1, ie = !0, w = !1, De = !1, be = !1, k = !1, ae = !1, re = !1, ot = !0, it = !1; const rn = "user-content-"; let Ne = !0, Z = !1, U = {}, F = null; const at = r({}, ["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"]); let rt = null; const st = r({}, ["audio", "video", "img", "source", "image", "track"]); let Ie = null; const lt = r({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), se = "http://www.w3.org/1998/Math/MathML", le = "http://www.w3.org/2000/svg", I = "http://www.w3.org/1999/xhtml"; let H = I, Me = !1, Ce = null; const sn = r({}, [se, le, I], pe); let ce = r({}, ["mi", "mo", "mn", "ms", "mtext"]), fe = r({}, ["annotation-xml"]); const ln = r({}, ["title", "style", "font", "a", "script"]); let J = null; const cn = ["application/xhtml+xml", "text/html"], fn = "text/html"; let d = null, z = null; const un = l.createElement("form"), ct = function(e) { return e instanceof RegExp || e instanceof Function; }, we = function() { let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; if (!(z && z === e)) { if ((!e || typeof e != "object") && (e = {}), e = N(e), J = // eslint-disable-next-line unicorn/prefer-includes cn.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? fn : e.PARSER_MEDIA_TYPE, d = J === "application/xhtml+xml" ? pe : ee, p = D(e, "ALLOWED_TAGS") ? r({}, e.ALLOWED_TAGS, d) : Je, T = D(e, "ALLOWED_ATTR") ? r({}, e.ALLOWED_ATTR, d) : Qe, Ce = D(e, "ALLOWED_NAMESPACES") ? r({}, e.ALLOWED_NAMESPACES, pe) : sn, Ie = D(e, "ADD_URI_SAFE_ATTR") ? r(N(lt), e.ADD_URI_SAFE_ATTR, d) : lt, rt = D(e, "ADD_DATA_URI_TAGS") ? r(N(st), e.ADD_DATA_URI_TAGS, d) : st, F = D(e, "FORBID_CONTENTS") ? r({}, e.FORBID_CONTENTS, d) : at, K = D(e, "FORBID_TAGS") ? r({}, e.FORBID_TAGS, d) : N({}), ye = D(e, "FORBID_ATTR") ? r({}, e.FORBID_ATTR, d) : N({}), U = D(e, "USE_PROFILES") ? e.USE_PROFILES : !1, et = e.ALLOW_ARIA_ATTR !== !1, Le = e.ALLOW_DATA_ATTR !== !1, tt = e.ALLOW_UNKNOWN_PROTOCOLS || !1, nt = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, v = e.SAFE_FOR_TEMPLATES || !1, ie = e.SAFE_FOR_XML !== !1, w = e.WHOLE_DOCUMENT || !1, k = e.RETURN_DOM || !1, ae = e.RETURN_DOM_FRAGMENT || !1, re = e.RETURN_TRUSTED_TYPE || !1, be = e.FORCE_BODY || !1, ot = e.SANITIZE_DOM !== !1, it = e.SANITIZE_NAMED_PROPS || !1, Ne = e.KEEP_CONTENT !== !1, Z = e.IN_PLACE || !1, Ze = e.ALLOWED_URI_REGEXP || Ye, H = e.NAMESPACE || I, ce = e.MATHML_TEXT_INTEGRATION_POINTS || ce, fe = e.HTML_INTEGRATION_POINTS || fe, u = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && ct(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (u.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && ct(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (u.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (u.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), v && (Le = !1), ae && (k = !0), U && (p = r({}, Ge), T = [], U.html === !0 && (r(p, ze), r(T, We)), U.svg === !0 && (r(p, Te), r(T, ge), r(T, te)), U.svgFilters === !0 && (r(p, Ee), r(T, ge), r(T, te)), U.mathMl === !0 && (r(p, _e), r(T, Be), r(T, te))), e.ADD_TAGS && (p === Je && (p = N(p)), r(p, e.ADD_TAGS, d)), e.ADD_ATTR && (T === Qe && (T = N(T)), r(T, e.ADD_ATTR, d)), e.ADD_URI_SAFE_ATTR && r(Ie, e.ADD_URI_SAFE_ATTR, d), e.FORBID_CONTENTS && (F === at && (F = N(F)), r(F, e.FORBID_CONTENTS, d)), Ne && (p["#text"] = !0), w && r(p, ["html", "head", "body"]), p.table && (r(p, ["tbody"]), delete K.tbody), e.TRUSTED_TYPES_POLICY) { if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function") throw Y('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw Y('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); S = e.TRUSTED_TYPES_POLICY, $ = S.createHTML(""); } else S === void 0 && (S = Wt(ne, c)), S !== null && typeof $ == "string" && ($ = S.createHTML("")); g && g(e), z = e; } }, ft = r({}, [...Te, ...Ee, ...Ct]), ut = r({}, [..._e, ...wt]), mn = function(e) { let t = oe(e); (!t || !t.tagName) && (t = { namespaceURI: H, tagName: "template" }); const n = ee(e.tagName), f = ee(t.tagName); return Ce[e.namespaceURI] ? e.namespaceURI === le ? t.namespaceURI === I ? n === "svg" : t.namespaceURI === se ? n === "svg" && (f === "annotation-xml" || ce[f]) : !!ft[n] : e.namespaceURI === se ? t.namespaceURI === I ? n === "math" : t.namespaceURI === le ? n === "math" && fe[f] : !!ut[n] : e.namespaceURI === I ? t.namespaceURI === le && !fe[f] || t.namespaceURI === se && !ce[f] ? !1 : !ut[n] && (ln[n] || !ft[n]) : !!(J === "application/xhtml+xml" && Ce[e.namespaceURI]) : !1; }, b = function(e) { W(o.removed, { element: e }); try { oe(e).removeChild(e); } catch { qt(e); } }, x = function(e, t) { try { W(o.removed, { attribute: t.getAttributeNode(e), from: t }); } catch { W(o.removed, { attribute: null, from: t }); } if (t.removeAttribute(e), e === "is") if (k || ae) try { b(t); } catch { } else try { t.setAttribute(e, ""); } catch { } }, mt = function(e) { let t = null, n = null; if (be) e = "<remove></remove>" + e; else { const m = de(e, /^[\r\n\t ]+/); n = m && m[0]; } J === "application/xhtml+xml" && H === I && (e = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + e + "</body></html>"); const f = S ? S.createHTML(e) : e; if (H === I) try { t = new jt().parseFromString(f, J); } catch { } if (!t || !t.documentElement) { t = Ae.createDocument(H, "template", null); try { t.documentElement.innerHTML = Me ? $ : f; } catch { } } const _ = t.body || t.documentElement; return e && n && _.insertBefore(l.createTextNode(n), _.childNodes[0] || null), H === I ? Qt.call(t, w ? "html" : "body")[0] : w ? t.documentElement : _; }, pt = function(e) { return Zt.call( e.ownerDocument || e, e, // eslint-disable-next-line no-bitwise V.SHOW_ELEMENT | V.SHOW_COMMENT | V.SHOW_TEXT | V.SHOW_PROCESSING_INSTRUCTION | V.SHOW_CDATA_SECTION, null ); }, xe = function(e) { return e instanceof Xt && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof Yt) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function"); }, dt = function(e) { return typeof he == "function" && e instanceof he; }; function M(i, e, t) { Q(i, (n) => { n.call(o, e, t, z); }); } const Tt = function(e) { let t = null; if (M(R.beforeSanitizeElements, e, null), xe(e)) return b(e), !0; const n = d(e.nodeName); if (M(R.uponSanitizeElement, e, { tagName: n, allowedTags: p }), ie && e.hasChildNodes() && !dt(e.firstElementChild) && h(/<[/\w!]/g, e.innerHTML) && h(/<[/\w!]/g, e.textContent) || e.nodeType === j.progressingInstruction || ie && e.nodeType === j.comment && h(/<[/\w]/g, e.data)) return b(e), !0; if (!p[n] || K[n]) { if (!K[n] && _t(n) && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, n) || u.tagNameCheck instanceof Function && u.tagNameCheck(n))) return !1; if (Ne && !F[n]) { const f = oe(e) || e.parentNode, _ = Kt(e) || e.childNodes; if (_ && f) { const m = _.length; for (let y = m - 1; y >= 0; --y) { const C = Vt(_[y], !0); C.__removalCount = (e.__removalCount || 0) + 1, f.insertBefore(C, $t(e)); } } } return b(e), !0; } return e instanceof $e && !mn(e) || (n === "noscript" || n === "noembed" || n === "noframes") && h(/<\/no(script|embed|frames)/i, e.innerHTML) ? (b(e), !0) : (v && e.nodeType === j.text && (t = e.textContent, Q([Se, Re, Oe], (f) => { t = B(t, f, " "); }), e.textContent !== t && (W(o.removed, { element: e.cloneNode() }), e.textContent = t)), M(R.afterSanitizeElements, e, null), !1); }, Et = function(e, t, n) { if (ot && (t === "id" || t === "name") && (n in l || n in un)) return !1; if (!(Le && !ye[t] && h(tn, t))) { if (!(et && h(nn, t))) { if (!T[t] || ye[t]) { if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck !(_t(e) && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, e) || u.tagNameCheck instanceof Function && u.tagNameCheck(e)) && (u.attributeNameCheck instanceof RegExp && h(u.attributeNameCheck, t) || u.attributeNameCheck instanceof Function && u.attributeNameCheck(t, e)) || // Alternative, second condition checks if it's an `is`-attribute, AND // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck t === "is" && u.allowCustomizedBuiltInElements && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, n) || u.tagNameCheck instanceof Function && u.tagNameCheck(n))) ) return !1; } else if (!Ie[t]) { if (!h(Ze, B(n, Ke, ""))) { if (!((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && bt(n, "data:") === 0 && rt[e])) { if (!(tt && !h(on, B(n, Ke, "")))) { if (n) return !1; } } } } } } return !0; }, _t = function(e) { return e !== "annotation-xml" && de(e, an); }, gt = function(e) { M(R.beforeSanitizeAttributes, e, null); const { attributes: t } = e; if (!t || xe(e)) return; const n = { attrName: "", attrValue: "", keepAttr: !0, allowedAttributes: T, forceKeepAttr: void 0 }; let f = t.length; for (; f--; ) { const _ = t[f], { name: m, namespaceURI: y, value: C } = _, G = d(m), Pe = C; let E = m === "value" ? Pe : Nt(Pe); if (n.attrName = G, n.attrValue = E, n.keepAttr = !0, n.forceKeepAttr = void 0, M(R.uponSanitizeAttribute, e, n), E = n.attrValue, it && (G === "id" || G === "name") && (x(m, e), E = rn + E), ie && h(/((--!?|])>)|<\/(style|title|textarea)/i, E)) { x(m, e); continue; } if (G === "attributename" && de(E, "href")) { x(m, e); continue; } if (n.forceKeepAttr) continue; if (!n.keepAttr) { x(m, e); continue; } if (!nt && h(/\/>/i, E)) { x(m, e); continue; } v && Q([Se, Re, Oe], (At) => { E = B(E, At, " "); }); const ht = d(e.nodeName); if (!Et(ht, G, E)) { x(m, e); continue; } if (S && typeof ne == "object" && typeof ne.getAttributeType == "function" && !y) switch (ne.getAttributeType(ht, G)) { case "TrustedHTML": { E = S.createHTML(E); break; } case "TrustedScriptURL": { E = S.createScriptURL(E); break; } } if (E !== Pe) try { y ? e.setAttributeNS(y, m, E) : e.setAttribute(m, E), xe(e) ? b(e) : He(o.removed); } catch { x(m, e); } } M(R.afterSanitizeAttributes, e, null); }, pn = function i(e) { let t = null; const n = pt(e); for (M(R.beforeSanitizeShadowDOM, e, null); t = n.nextNode(); ) M(R.uponSanitizeShadowNode, t, null), Tt(t), gt(t), t.content instanceof O && i(t.content); M(R.afterSanitizeShadowDOM, e, null); }; return o.sanitize = function(i) { let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, t = null, n = null, f = null, _ = null; if (Me = !i, Me && (i = "<!-->"), typeof i != "string" && !dt(i)) if (typeof i.toString == "function") { if (i = i.toString(), typeof i != "string") throw Y("dirty is not a string, aborting"); } else throw Y("toString is not a function"); if (!o.isSupported) return i; if (De || we(e), o.removed = [], typeof i == "string" && (Z = !1), Z) { if (i.nodeName) { const C = d(i.nodeName); if (!p[C] || K[C]) throw Y("root node is forbidden and cannot be sanitized in-place"); } } else if (i instanceof he) t = mt("<!---->"), n = t.ownerDocument.importNode(i, !0), n.nodeType === j.element && n.nodeName === "BODY" || n.nodeName === "HTML" ? t = n : t.appendChild(n); else { if (!k && !v && !w && // eslint-disable-next-line unicorn/prefer-includes i.indexOf("<") === -1) return S && re ? S.createHTML(i) : i; if (t = mt(i), !t) return k ? null : re ? $ : ""; } t && be && b(t.firstChild); const m = pt(Z ? i : t); for (; f = m.nextNode(); ) Tt(f), gt(f), f.content instanceof O && pn(f.content); if (Z) return i; if (k) { if (ae) for (_ = Jt.call(t.ownerDocument); t.firstChild; ) _.appendChild(t.firstChild); else _ = t; return (T.shadowroot || T.shadowrootmode) && (_ = en.call(a, _, !0)), _; } let y = w ? t.outerHTML : t.innerHTML; return w && p["!doctype"] && t.ownerDocument && t.ownerDocument.doctype && t.ownerDocument.doctype.name && h(Xe, t.ownerDocument.doctype.name) && (y = "<!DOCTYPE " + t.ownerDocument.doctype.name + `> ` + y), v && Q([Se, Re, Oe], (C) => { y = B(y, C, " "); }), S && re ? S.createHTML(y) : y; }, o.setConfig = function() { let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; we(i), De = !0; }, o.clearConfig = function() { z = null, De = !1; }, o.isValidAttribute = function(i, e, t) { z || we({}); const n = d(i), f = d(e); return Et(n, f, t); }, o.addHook = function(i, e) { typeof e == "function" && W(R[i], e); }, o.removeHook = function(i, e) { if (e !== void 0) { const t = Lt(R[i], e); return t === -1 ? void 0 : Dt(R[i], t, 1)[0]; } return He(R[i]); }, o.removeHooks = function(i) { R[i] = []; }, o.removeAllHooks = function() { R = Ve(); }, o; } var Bt = qe(); return ve = Bt, ve; } export { dn as __require }; //# sourceMappingURL=index.es460.js.map