import { DEFAULT_FORBIDDEN_TAGS as Yt } from "./constants.es.js";
const {
  entries: _t,
  setPrototypeOf: ct,
  isFrozen: Xt,
  getPrototypeOf: jt,
  getOwnPropertyDescriptor: Vt
} = Object;
let {
  freeze: R,
  seal: b,
  create: ve
} = Object, {
  apply: ke,
  construct: Ue
} = typeof Reflect < "u" && Reflect;
R || (R = function(o) {
  return o;
});
b || (b = function(o) {
  return o;
});
ke || (ke = function(o, l) {
  for (var a = arguments.length, c = new Array(a > 2 ? a - 2 : 0), _ = 2; _ < a; _++)
    c[_ - 2] = arguments[_];
  return o.apply(l, c);
});
Ue || (Ue = 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 ce = /* @__PURE__ */ O(Array.prototype.forEach), $t = /* @__PURE__ */ O(Array.prototype.lastIndexOf), ft = /* @__PURE__ */ O(Array.prototype.pop), q = /* @__PURE__ */ O(Array.prototype.push), qt = /* @__PURE__ */ O(Array.prototype.splice), ue = /* @__PURE__ */ O(String.prototype.toLowerCase), Ie = /* @__PURE__ */ O(String.prototype.toString), Ce = /* @__PURE__ */ O(String.prototype.match), K = /* @__PURE__ */ O(String.prototype.replace), Kt = /* @__PURE__ */ O(String.prototype.indexOf), Zt = /* @__PURE__ */ O(String.prototype.trim), y = /* @__PURE__ */ O(Object.prototype.hasOwnProperty), S = /* @__PURE__ */ O(RegExp.prototype.test), Z = /* @__PURE__ */ Jt(TypeError);
function O(r) {
  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 ke(r, o, a);
  };
}
function Jt(r) {
  return function() {
    for (var o = arguments.length, l = new Array(o), a = 0; a < o; a++)
      l[a] = arguments[a];
    return Ue(r, l);
  };
}
function s(r, o) {
  let l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ue;
  ct && ct(r, null);
  let a = o.length;
  for (; a--; ) {
    let c = o[a];
    if (typeof c == "string") {
      const _ = l(c);
      _ !== c && (Xt(o) || (o[a] = _), c = _);
    }
    r[c] = !0;
  }
  return r;
}
function Qt(r) {
  for (let o = 0; o < r.length; o++)
    y(r, o) || (r[o] = null);
  return r;
}
function I(r) {
  const o = ve(null);
  for (const [l, a] of _t(r))
    y(r, l) && (Array.isArray(a) ? o[l] = Qt(a) : a && typeof a == "object" && a.constructor === Object ? o[l] = I(a) : o[l] = a);
  return o;
}
function J(r, o) {
  for (; r !== null; ) {
    const a = Vt(r, o);
    if (a) {
      if (a.get)
        return O(a.get);
      if (typeof a.value == "function")
        return O(a.value);
    }
    r = jt(r);
  }
  function l() {
    return null;
  }
  return l;
}
const ut = /* @__PURE__ */ R(["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"]), Me = /* @__PURE__ */ R(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), we = /* @__PURE__ */ R(["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"]), en = /* @__PURE__ */ R(["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"]), xe = /* @__PURE__ */ R(["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"]), tn = /* @__PURE__ */ R(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), mt = /* @__PURE__ */ R(["#text"]), pt = /* @__PURE__ */ R(["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"]), Pe = /* @__PURE__ */ R(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), dt = /* @__PURE__ */ R(["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"]), fe = /* @__PURE__ */ R(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), nn = /* @__PURE__ */ b(/\{\{[\w\W]*|[\w\W]*\}\}/gm), on = /* @__PURE__ */ b(/<%[\w\W]*|[\w\W]*%>/gm), an = /* @__PURE__ */ b(/\$\{[\w\W]*/gm), rn = /* @__PURE__ */ b(/^data-[\-\w.\u00B7-\uFFFF]+$/), sn = /* @__PURE__ */ b(/^aria-[\-\w]+$/), At = /* @__PURE__ */ b(
  /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
  // eslint-disable-line no-useless-escape
), ln = /* @__PURE__ */ b(/^(?:\w+script|data):/i), cn = /* @__PURE__ */ b(
  /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
  // eslint-disable-line no-control-regex
), gt = /* @__PURE__ */ b(/^html$/i), fn = /* @__PURE__ */ b(/^[a-z][.\w]*(-[.\w]+)+$/i);
var Tt = /* @__PURE__ */ Object.freeze({
  __proto__: null,
  ARIA_ATTR: sn,
  ATTR_WHITESPACE: cn,
  CUSTOM_ELEMENT: fn,
  DATA_ATTR: rn,
  DOCTYPE_NAME: gt,
  ERB_EXPR: on,
  IS_ALLOWED_URI: At,
  IS_SCRIPT_OR_DATA: ln,
  MUSTACHE_EXPR: nn,
  TMPLIT_EXPR: an
});
const Q = {
  element: 1,
  text: 3,
  // Deprecated
  progressingInstruction: 7,
  comment: 8,
  document: 9
}, un = function() {
  return typeof window > "u" ? null : window;
}, mn = 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 _ = "dompurify" + (a ? "#" + a : "");
  try {
    return o.createPolicy(_, {
      createHTML(x) {
        return x;
      },
      createScriptURL(x) {
        return x;
      }
    });
  } catch {
    return console.warn("TrustedTypes policy " + _ + " could not be created."), null;
  }
}, Et = function() {
  return {
    afterSanitizeAttributes: [],
    afterSanitizeElements: [],
    afterSanitizeShadowDOM: [],
    beforeSanitizeAttributes: [],
    beforeSanitizeElements: [],
    beforeSanitizeShadowDOM: [],
    uponSanitizeAttribute: [],
    uponSanitizeElement: [],
    uponSanitizeShadowNode: []
  };
};
function ht() {
  let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : un();
  const o = (i) => ht(i);
  if (o.version = "3.3.1", o.removed = [], !r || !r.document || r.document.nodeType !== Q.document || !r.Element)
    return o.isSupported = !1, o;
  let {
    document: l
  } = r;
  const a = l, c = a.currentScript, {
    DocumentFragment: _,
    HTMLTemplateElement: x,
    Node: me,
    Element: Fe,
    NodeFilter: B,
    NamedNodeMap: St = r.NamedNodeMap || r.MozNamedAttrMap,
    HTMLFormElement: Rt,
    DOMParser: Ot,
    trustedTypes: ee
  } = r, Y = Fe.prototype, Dt = J(Y, "cloneNode"), bt = J(Y, "remove"), yt = J(Y, "nextSibling"), Lt = J(Y, "childNodes"), te = J(Y, "parentNode");
  if (typeof x == "function") {
    const i = l.createElement("template");
    i.content && i.content.ownerDocument && (l = i.content.ownerDocument);
  }
  let g, X = "";
  const {
    implementation: pe,
    createNodeIterator: Nt,
    createDocumentFragment: It,
    getElementsByTagName: Ct
  } = l, {
    importNode: Mt
  } = a;
  let h = Et();
  o.isSupported = typeof _t == "function" && typeof te == "function" && pe && pe.createHTMLDocument !== void 0;
  const {
    MUSTACHE_EXPR: de,
    ERB_EXPR: Te,
    TMPLIT_EXPR: Ee,
    DATA_ATTR: wt,
    ARIA_ATTR: xt,
    IS_SCRIPT_OR_DATA: Pt,
    ATTR_WHITESPACE: He,
    CUSTOM_ELEMENT: vt
  } = Tt;
  let {
    IS_ALLOWED_URI: ze
  } = Tt, d = null;
  const Ge = s({}, [...ut, ...Me, ...we, ...xe, ...mt]);
  let T = null;
  const We = s({}, [...pt, ...Pe, ...dt, ...fe]);
  let u = Object.seal(ve(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
    }
  })), j = null, _e = null;
  const k = Object.seal(ve(null, {
    tagCheck: {
      writable: !0,
      configurable: !1,
      enumerable: !0,
      value: null
    },
    attributeCheck: {
      writable: !0,
      configurable: !1,
      enumerable: !0,
      value: null
    }
  }));
  let Be = !0, Ae = !0, Ye = !1, Xe = !0, U = !1, ne = !0, P = !1, ge = !1, he = !1, F = !1, oe = !1, ie = !1, je = !0, Ve = !1;
  const kt = "user-content-";
  let Se = !0, V = !1, H = {}, L = null;
  const Re = s({}, ["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 $e = null;
  const qe = s({}, ["audio", "video", "img", "source", "image", "track"]);
  let Oe = null;
  const Ke = s({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), ae = "http://www.w3.org/1998/Math/MathML", re = "http://www.w3.org/2000/svg", C = "http://www.w3.org/1999/xhtml";
  let z = C, De = !1, be = null;
  const Ut = s({}, [ae, re, C], Ie);
  let se = s({}, ["mi", "mo", "mn", "ms", "mtext"]), le = s({}, ["annotation-xml"]);
  const Ft = s({}, ["title", "style", "font", "a", "script"]);
  let $ = null;
  const Ht = ["application/xhtml+xml", "text/html"], zt = "text/html";
  let p = null, G = null;
  const Gt = l.createElement("form"), Ze = function(e) {
    return e instanceof RegExp || e instanceof Function;
  }, ye = function() {
    let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
    if (!(G && G === e)) {
      if ((!e || typeof e != "object") && (e = {}), e = I(e), $ = // eslint-disable-next-line unicorn/prefer-includes
      Ht.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? zt : e.PARSER_MEDIA_TYPE, p = $ === "application/xhtml+xml" ? Ie : ue, d = y(e, "ALLOWED_TAGS") ? s({}, e.ALLOWED_TAGS, p) : Ge, T = y(e, "ALLOWED_ATTR") ? s({}, e.ALLOWED_ATTR, p) : We, be = y(e, "ALLOWED_NAMESPACES") ? s({}, e.ALLOWED_NAMESPACES, Ie) : Ut, Oe = y(e, "ADD_URI_SAFE_ATTR") ? s(I(Ke), e.ADD_URI_SAFE_ATTR, p) : Ke, $e = y(e, "ADD_DATA_URI_TAGS") ? s(I(qe), e.ADD_DATA_URI_TAGS, p) : qe, L = y(e, "FORBID_CONTENTS") ? s({}, e.FORBID_CONTENTS, p) : Re, j = y(e, "FORBID_TAGS") ? s({}, e.FORBID_TAGS, p) : I({}), _e = y(e, "FORBID_ATTR") ? s({}, e.FORBID_ATTR, p) : I({}), H = y(e, "USE_PROFILES") ? e.USE_PROFILES : !1, Be = e.ALLOW_ARIA_ATTR !== !1, Ae = e.ALLOW_DATA_ATTR !== !1, Ye = e.ALLOW_UNKNOWN_PROTOCOLS || !1, Xe = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, U = e.SAFE_FOR_TEMPLATES || !1, ne = e.SAFE_FOR_XML !== !1, P = e.WHOLE_DOCUMENT || !1, F = e.RETURN_DOM || !1, oe = e.RETURN_DOM_FRAGMENT || !1, ie = e.RETURN_TRUSTED_TYPE || !1, he = e.FORCE_BODY || !1, je = e.SANITIZE_DOM !== !1, Ve = e.SANITIZE_NAMED_PROPS || !1, Se = e.KEEP_CONTENT !== !1, V = e.IN_PLACE || !1, ze = e.ALLOWED_URI_REGEXP || At, z = e.NAMESPACE || C, se = e.MATHML_TEXT_INTEGRATION_POINTS || se, le = e.HTML_INTEGRATION_POINTS || le, u = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && Ze(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (u.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && Ze(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), U && (Ae = !1), oe && (F = !0), H && (d = s({}, mt), T = [], H.html === !0 && (s(d, ut), s(T, pt)), H.svg === !0 && (s(d, Me), s(T, Pe), s(T, fe)), H.svgFilters === !0 && (s(d, we), s(T, Pe), s(T, fe)), H.mathMl === !0 && (s(d, xe), s(T, dt), s(T, fe))), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? k.tagCheck = e.ADD_TAGS : (d === Ge && (d = I(d)), s(d, e.ADD_TAGS, p))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? k.attributeCheck = e.ADD_ATTR : (T === We && (T = I(T)), s(T, e.ADD_ATTR, p))), e.ADD_URI_SAFE_ATTR && s(Oe, e.ADD_URI_SAFE_ATTR, p), e.FORBID_CONTENTS && (L === Re && (L = I(L)), s(L, e.FORBID_CONTENTS, p)), e.ADD_FORBID_CONTENTS && (L === Re && (L = I(L)), s(L, e.ADD_FORBID_CONTENTS, p)), Se && (d["#text"] = !0), P && s(d, ["html", "head", "body"]), d.table && (s(d, ["tbody"]), delete j.tbody), e.TRUSTED_TYPES_POLICY) {
        if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function")
          throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
        if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function")
          throw Z('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
        g = e.TRUSTED_TYPES_POLICY, X = g.createHTML("");
      } else
        g === void 0 && (g = mn(ee, c)), g !== null && typeof X == "string" && (X = g.createHTML(""));
      R && R(e), G = e;
    }
  }, Je = s({}, [...Me, ...we, ...en]), Qe = s({}, [...xe, ...tn]), Wt = function(e) {
    let t = te(e);
    (!t || !t.tagName) && (t = {
      namespaceURI: z,
      tagName: "template"
    });
    const n = ue(e.tagName), f = ue(t.tagName);
    return be[e.namespaceURI] ? e.namespaceURI === re ? t.namespaceURI === C ? n === "svg" : t.namespaceURI === ae ? n === "svg" && (f === "annotation-xml" || se[f]) : !!Je[n] : e.namespaceURI === ae ? t.namespaceURI === C ? n === "math" : t.namespaceURI === re ? n === "math" && le[f] : !!Qe[n] : e.namespaceURI === C ? t.namespaceURI === re && !le[f] || t.namespaceURI === ae && !se[f] ? !1 : !Qe[n] && (Ft[n] || !Je[n]) : !!($ === "application/xhtml+xml" && be[e.namespaceURI]) : !1;
  }, N = function(e) {
    q(o.removed, {
      element: e
    });
    try {
      te(e).removeChild(e);
    } catch {
      bt(e);
    }
  }, v = function(e, t) {
    try {
      q(o.removed, {
        attribute: t.getAttributeNode(e),
        from: t
      });
    } catch {
      q(o.removed, {
        attribute: null,
        from: t
      });
    }
    if (t.removeAttribute(e), e === "is")
      if (F || oe)
        try {
          N(t);
        } catch {
        }
      else
        try {
          t.setAttribute(e, "");
        } catch {
        }
  }, et = function(e) {
    let t = null, n = null;
    if (he)
      e = "<remove></remove>" + e;
    else {
      const m = Ce(e, /^[\r\n\t ]+/);
      n = m && m[0];
    }
    $ === "application/xhtml+xml" && z === C && (e = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + e + "</body></html>");
    const f = g ? g.createHTML(e) : e;
    if (z === C)
      try {
        t = new Ot().parseFromString(f, $);
      } catch {
      }
    if (!t || !t.documentElement) {
      t = pe.createDocument(z, "template", null);
      try {
        t.documentElement.innerHTML = De ? X : f;
      } catch {
      }
    }
    const A = t.body || t.documentElement;
    return e && n && A.insertBefore(l.createTextNode(n), A.childNodes[0] || null), z === C ? Ct.call(t, P ? "html" : "body")[0] : P ? t.documentElement : A;
  }, tt = function(e) {
    return Nt.call(
      e.ownerDocument || e,
      e,
      // eslint-disable-next-line no-bitwise
      B.SHOW_ELEMENT | B.SHOW_COMMENT | B.SHOW_TEXT | B.SHOW_PROCESSING_INSTRUCTION | B.SHOW_CDATA_SECTION,
      null
    );
  }, Le = function(e) {
    return e instanceof Rt && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof St) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
  }, nt = function(e) {
    return typeof me == "function" && e instanceof me;
  };
  function M(i, e, t) {
    ce(i, (n) => {
      n.call(o, e, t, G);
    });
  }
  const ot = function(e) {
    let t = null;
    if (M(h.beforeSanitizeElements, e, null), Le(e))
      return N(e), !0;
    const n = p(e.nodeName);
    if (M(h.uponSanitizeElement, e, {
      tagName: n,
      allowedTags: d
    }), ne && e.hasChildNodes() && !nt(e.firstElementChild) && S(/<[/\w!]/g, e.innerHTML) && S(/<[/\w!]/g, e.textContent) || e.nodeType === Q.progressingInstruction || ne && e.nodeType === Q.comment && S(/<[/\w]/g, e.data))
      return N(e), !0;
    if (!(k.tagCheck instanceof Function && k.tagCheck(n)) && (!d[n] || j[n])) {
      if (!j[n] && at(n) && (u.tagNameCheck instanceof RegExp && S(u.tagNameCheck, n) || u.tagNameCheck instanceof Function && u.tagNameCheck(n)))
        return !1;
      if (Se && !L[n]) {
        const f = te(e) || e.parentNode, A = Lt(e) || e.childNodes;
        if (A && f) {
          const m = A.length;
          for (let D = m - 1; D >= 0; --D) {
            const w = Dt(A[D], !0);
            w.__removalCount = (e.__removalCount || 0) + 1, f.insertBefore(w, yt(e));
          }
        }
      }
      return N(e), !0;
    }
    return e instanceof Fe && !Wt(e) || (n === "noscript" || n === "noembed" || n === "noframes") && S(/<\/no(script|embed|frames)/i, e.innerHTML) ? (N(e), !0) : (U && e.nodeType === Q.text && (t = e.textContent, ce([de, Te, Ee], (f) => {
      t = K(t, f, " ");
    }), e.textContent !== t && (q(o.removed, {
      element: e.cloneNode()
    }), e.textContent = t)), M(h.afterSanitizeElements, e, null), !1);
  }, it = function(e, t, n) {
    if (je && (t === "id" || t === "name") && (n in l || n in Gt))
      return !1;
    if (!(Ae && !_e[t] && S(wt, t))) {
      if (!(Be && S(xt, t))) {
        if (!(k.attributeCheck instanceof Function && k.attributeCheck(t, e))) {
          if (!T[t] || _e[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
              !(at(e) && (u.tagNameCheck instanceof RegExp && S(u.tagNameCheck, e) || u.tagNameCheck instanceof Function && u.tagNameCheck(e)) && (u.attributeNameCheck instanceof RegExp && S(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 && S(u.tagNameCheck, n) || u.tagNameCheck instanceof Function && u.tagNameCheck(n)))
            ) return !1;
          } else if (!Oe[t]) {
            if (!S(ze, K(n, He, ""))) {
              if (!((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && Kt(n, "data:") === 0 && $e[e])) {
                if (!(Ye && !S(Pt, K(n, He, "")))) {
                  if (n)
                    return !1;
                }
              }
            }
          }
        }
      }
    }
    return !0;
  }, at = function(e) {
    return e !== "annotation-xml" && Ce(e, vt);
  }, rt = function(e) {
    M(h.beforeSanitizeAttributes, e, null);
    const {
      attributes: t
    } = e;
    if (!t || Le(e))
      return;
    const n = {
      attrName: "",
      attrValue: "",
      keepAttr: !0,
      allowedAttributes: T,
      forceKeepAttr: void 0
    };
    let f = t.length;
    for (; f--; ) {
      const A = t[f], {
        name: m,
        namespaceURI: D,
        value: w
      } = A, W = p(m), Ne = w;
      let E = m === "value" ? Ne : Zt(Ne);
      if (n.attrName = W, n.attrValue = E, n.keepAttr = !0, n.forceKeepAttr = void 0, M(h.uponSanitizeAttribute, e, n), E = n.attrValue, Ve && (W === "id" || W === "name") && (v(m, e), E = kt + E), ne && S(/((--!?|])>)|<\/(style|title|textarea)/i, E)) {
        v(m, e);
        continue;
      }
      if (W === "attributename" && Ce(E, "href")) {
        v(m, e);
        continue;
      }
      if (n.forceKeepAttr)
        continue;
      if (!n.keepAttr) {
        v(m, e);
        continue;
      }
      if (!Xe && S(/\/>/i, E)) {
        v(m, e);
        continue;
      }
      U && ce([de, Te, Ee], (lt) => {
        E = K(E, lt, " ");
      });
      const st = p(e.nodeName);
      if (!it(st, W, E)) {
        v(m, e);
        continue;
      }
      if (g && typeof ee == "object" && typeof ee.getAttributeType == "function" && !D)
        switch (ee.getAttributeType(st, W)) {
          case "TrustedHTML": {
            E = g.createHTML(E);
            break;
          }
          case "TrustedScriptURL": {
            E = g.createScriptURL(E);
            break;
          }
        }
      if (E !== Ne)
        try {
          D ? e.setAttributeNS(D, m, E) : e.setAttribute(m, E), Le(e) ? N(e) : ft(o.removed);
        } catch {
          v(m, e);
        }
    }
    M(h.afterSanitizeAttributes, e, null);
  }, Bt = function i(e) {
    let t = null;
    const n = tt(e);
    for (M(h.beforeSanitizeShadowDOM, e, null); t = n.nextNode(); )
      M(h.uponSanitizeShadowNode, t, null), ot(t), rt(t), t.content instanceof _ && i(t.content);
    M(h.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, A = null;
    if (De = !i, De && (i = "<!-->"), typeof i != "string" && !nt(i))
      if (typeof i.toString == "function") {
        if (i = i.toString(), typeof i != "string")
          throw Z("dirty is not a string, aborting");
      } else
        throw Z("toString is not a function");
    if (!o.isSupported)
      return i;
    if (ge || ye(e), o.removed = [], typeof i == "string" && (V = !1), V) {
      if (i.nodeName) {
        const w = p(i.nodeName);
        if (!d[w] || j[w])
          throw Z("root node is forbidden and cannot be sanitized in-place");
      }
    } else if (i instanceof me)
      t = et("<!---->"), n = t.ownerDocument.importNode(i, !0), n.nodeType === Q.element && n.nodeName === "BODY" || n.nodeName === "HTML" ? t = n : t.appendChild(n);
    else {
      if (!F && !U && !P && // eslint-disable-next-line unicorn/prefer-includes
      i.indexOf("<") === -1)
        return g && ie ? g.createHTML(i) : i;
      if (t = et(i), !t)
        return F ? null : ie ? X : "";
    }
    t && he && N(t.firstChild);
    const m = tt(V ? i : t);
    for (; f = m.nextNode(); )
      ot(f), rt(f), f.content instanceof _ && Bt(f.content);
    if (V)
      return i;
    if (F) {
      if (oe)
        for (A = It.call(t.ownerDocument); t.firstChild; )
          A.appendChild(t.firstChild);
      else
        A = t;
      return (T.shadowroot || T.shadowrootmode) && (A = Mt.call(a, A, !0)), A;
    }
    let D = P ? t.outerHTML : t.innerHTML;
    return P && d["!doctype"] && t.ownerDocument && t.ownerDocument.doctype && t.ownerDocument.doctype.name && S(gt, t.ownerDocument.doctype.name) && (D = "<!DOCTYPE " + t.ownerDocument.doctype.name + `>
` + D), U && ce([de, Te, Ee], (w) => {
      D = K(D, w, " ");
    }), g && ie ? g.createHTML(D) : D;
  }, o.setConfig = function() {
    let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
    ye(i), ge = !0;
  }, o.clearConfig = function() {
    G = null, ge = !1;
  }, o.isValidAttribute = function(i, e, t) {
    G || ye({});
    const n = p(i), f = p(e);
    return it(n, f, t);
  }, o.addHook = function(i, e) {
    typeof e == "function" && q(h[i], e);
  }, o.removeHook = function(i, e) {
    if (e !== void 0) {
      const t = $t(h[i], e);
      return t === -1 ? void 0 : qt(h[i], t, 1)[0];
    }
    return ft(h[i]);
  }, o.removeHooks = function(i) {
    h[i] = [];
  }, o.removeAllHooks = function() {
    h = Et();
  }, o;
}
var pn = /* @__PURE__ */ ht();
function En(r, o = {}) {
  const {
    allowStyles: l = !1,
    forbiddenAttributes: a = [],
    forbiddenTags: c = []
  } = o;
  if (!r || typeof r != "string")
    return null;
  if (!dn())
    return r;
  const _ = [...Yt, ...c], x = [
    ...l ? [] : ["style"],
    ...a
  ];
  return pn.sanitize(r, {
    USE_PROFILES: { svg: !0, svgFilters: !0 },
    FORBID_TAGS: _,
    FORBID_ATTR: x
  });
}
function dn() {
  return !!(typeof window < "u" && window.document && window.document.createElement);
}
export {
  dn as canUseDOM,
  En as sanitizeSvg
};
//# sourceMappingURL=utils.es.js.map
