"use client";
import { NS as n, TAG_ID as e, ATTRS as s, getTagID as f } from "./html.js";
const o = {
  TEXT_HTML: "text/html",
  APPLICATION_XML: "application/xhtml+xml"
}, m = "definitionurl", p = "definitionURL", T = new Map([
  "attributeName",
  "attributeType",
  "baseFrequency",
  "baseProfile",
  "calcMode",
  "clipPathUnits",
  "diffuseConstant",
  "edgeMode",
  "filterUnits",
  "glyphRef",
  "gradientTransform",
  "gradientUnits",
  "kernelMatrix",
  "kernelUnitLength",
  "keyPoints",
  "keySplines",
  "keyTimes",
  "lengthAdjust",
  "limitingConeAngle",
  "markerHeight",
  "markerUnits",
  "markerWidth",
  "maskContentUnits",
  "maskUnits",
  "numOctaves",
  "pathLength",
  "patternContentUnits",
  "patternTransform",
  "patternUnits",
  "pointsAtX",
  "pointsAtY",
  "pointsAtZ",
  "preserveAlpha",
  "preserveAspectRatio",
  "primitiveUnits",
  "refX",
  "refY",
  "repeatCount",
  "repeatDur",
  "requiredExtensions",
  "requiredFeatures",
  "specularConstant",
  "specularExponent",
  "spreadMethod",
  "startOffset",
  "stdDeviation",
  "stitchTiles",
  "surfaceScale",
  "systemLanguage",
  "tableValues",
  "targetX",
  "targetY",
  "textLength",
  "viewBox",
  "viewTarget",
  "xChannelSelector",
  "yChannelSelector",
  "zoomAndPan"
].map((t) => [t.toLowerCase(), t])), c = /* @__PURE__ */ new Map([
  ["xlink:actuate", { prefix: "xlink", name: "actuate", namespace: n.XLINK }],
  ["xlink:arcrole", { prefix: "xlink", name: "arcrole", namespace: n.XLINK }],
  ["xlink:href", { prefix: "xlink", name: "href", namespace: n.XLINK }],
  ["xlink:role", { prefix: "xlink", name: "role", namespace: n.XLINK }],
  ["xlink:show", { prefix: "xlink", name: "show", namespace: n.XLINK }],
  ["xlink:title", { prefix: "xlink", name: "title", namespace: n.XLINK }],
  ["xlink:type", { prefix: "xlink", name: "type", namespace: n.XLINK }],
  ["xml:lang", { prefix: "xml", name: "lang", namespace: n.XML }],
  ["xml:space", { prefix: "xml", name: "space", namespace: n.XML }],
  ["xmlns", { prefix: "", name: "xmlns", namespace: n.XMLNS }],
  ["xmlns:xlink", { prefix: "xmlns", name: "xlink", namespace: n.XMLNS }]
]), M = new Map([
  "altGlyph",
  "altGlyphDef",
  "altGlyphItem",
  "animateColor",
  "animateMotion",
  "animateTransform",
  "clipPath",
  "feBlend",
  "feColorMatrix",
  "feComponentTransfer",
  "feComposite",
  "feConvolveMatrix",
  "feDiffuseLighting",
  "feDisplacementMap",
  "feDistantLight",
  "feFlood",
  "feFuncA",
  "feFuncB",
  "feFuncG",
  "feFuncR",
  "feGaussianBlur",
  "feImage",
  "feMerge",
  "feMergeNode",
  "feMorphology",
  "feOffset",
  "fePointLight",
  "feSpecularLighting",
  "feSpotLight",
  "feTile",
  "feTurbulence",
  "foreignObject",
  "glyphRef",
  "linearGradient",
  "radialGradient",
  "textPath"
].map((t) => [t.toLowerCase(), t])), u = /* @__PURE__ */ new Set([
  e.B,
  e.BIG,
  e.BLOCKQUOTE,
  e.BODY,
  e.BR,
  e.CENTER,
  e.CODE,
  e.DD,
  e.DIV,
  e.DL,
  e.DT,
  e.EM,
  e.EMBED,
  e.H1,
  e.H2,
  e.H3,
  e.H4,
  e.H5,
  e.H6,
  e.HEAD,
  e.HR,
  e.I,
  e.IMG,
  e.LI,
  e.LISTING,
  e.MENU,
  e.META,
  e.NOBR,
  e.OL,
  e.P,
  e.PRE,
  e.RUBY,
  e.S,
  e.SMALL,
  e.SPAN,
  e.STRONG,
  e.STRIKE,
  e.SUB,
  e.SUP,
  e.TABLE,
  e.TT,
  e.U,
  e.UL,
  e.VAR
]);
function g(t) {
  const a = t.tagID;
  return a === e.FONT && t.attrs.some(({ name: r }) => r === s.COLOR || r === s.SIZE || r === s.FACE) || u.has(a);
}
function I(t) {
  for (let a = 0; a < t.attrs.length; a++)
    if (t.attrs[a].name === m) {
      t.attrs[a].name = p;
      break;
    }
}
function N(t) {
  for (let a = 0; a < t.attrs.length; a++) {
    const i = T.get(t.attrs[a].name);
    i != null && (t.attrs[a].name = i);
  }
}
function h(t) {
  for (let a = 0; a < t.attrs.length; a++) {
    const i = c.get(t.attrs[a].name);
    i && (t.attrs[a].prefix = i.prefix, t.attrs[a].name = i.name, t.attrs[a].namespace = i.namespace);
  }
}
function E(t) {
  const a = M.get(t.tagName);
  a != null && (t.tagName = a, t.tagID = f(t.tagName));
}
function x(t, a) {
  return a === n.MATHML && (t === e.MI || t === e.MO || t === e.MN || t === e.MS || t === e.MTEXT);
}
function L(t, a, i) {
  if (a === n.MATHML && t === e.ANNOTATION_XML) {
    for (let r = 0; r < i.length; r++)
      if (i[r].name === s.ENCODING) {
        const l = i[r].value.toLowerCase();
        return l === o.TEXT_HTML || l === o.APPLICATION_XML;
      }
  }
  return a === n.SVG && (t === e.FOREIGN_OBJECT || t === e.DESC || t === e.TITLE);
}
function S(t, a, i, r) {
  return (!r || r === n.HTML) && L(t, a, i) || (!r || r === n.MATHML) && x(t, a);
}
export {
  M as SVG_TAG_NAMES_ADJUSTMENT_MAP,
  I as adjustTokenMathMLAttrs,
  N as adjustTokenSVGAttrs,
  E as adjustTokenSVGTagName,
  h as adjustTokenXMLAttrs,
  g as causesExit,
  S as isIntegrationPoint
};
