import { B as tags, Et as EditorSelection, I as syntaxTree, J as parseMixed, O as indentNodeProp, Z as EditorView, m as bracketMatchingHandle, n as ExternalTokenizer, r as LRParser, s as LRLanguage, t as ContextTracker, u as LanguageSupport, w as foldNodeProp, z as styleTags } from "./dist-CCADb07R.js";
import { r as cssLanguage, t as css } from "./dist-BTyJtnNg.js";
import { c as typescriptLanguage, i as jsxLanguage, n as javascript, r as javascriptLanguage, s as tsxLanguage } from "./dist-DGAfI2rB.js";
var scriptText = 54, StartCloseScriptTag = 1, styleText = 55, StartCloseStyleTag = 2, textareaText = 56, StartCloseTextareaTag = 3, EndTag = 4, SelfClosingEndTag = 5, StartTag = 6, StartScriptTag = 7, StartStyleTag = 8, StartTextareaTag = 9, StartSelfClosingTag = 10, StartCloseTag = 11, NoMatchStartCloseTag = 12, MismatchedStartCloseTag = 13, missingCloseTag = 57, IncompleteCloseTag = 14, commentContent$1 = 58, Element = 20, TagName = 22, Attribute = 23, AttributeName = 24, AttributeValue = 26, UnquotedAttributeValue = 27, ScriptText = 28, StyleText = 31, TextareaText = 34, OpenTag = 36, CloseTag = 37, Dialect_noMatch = 0, Dialect_selfClosing = 1, selfClosers$1 = {
  area: true,
  base: true,
  br: true,
  col: true,
  command: true,
  embed: true,
  frame: true,
  hr: true,
  img: true,
  input: true,
  keygen: true,
  link: true,
  meta: true,
  param: true,
  source: true,
  track: true,
  wbr: true,
  menuitem: true
}, implicitlyClosed = {
  dd: true,
  li: true,
  optgroup: true,
  option: true,
  p: true,
  rp: true,
  rt: true,
  tbody: true,
  td: true,
  tfoot: true,
  th: true,
  tr: true
}, closeOnOpen = {
  dd: {
    dd: true,
    dt: true
  },
  dt: {
    dd: true,
    dt: true
  },
  li: { li: true },
  option: {
    option: true,
    optgroup: true
  },
  optgroup: { optgroup: true },
  p: {
    address: true,
    article: true,
    aside: true,
    blockquote: true,
    dir: true,
    div: true,
    dl: true,
    fieldset: true,
    footer: true,
    form: true,
    h1: true,
    h2: true,
    h3: true,
    h4: true,
    h5: true,
    h6: true,
    header: true,
    hgroup: true,
    hr: true,
    menu: true,
    nav: true,
    ol: true,
    p: true,
    pre: true,
    section: true,
    table: true,
    ul: true
  },
  rp: {
    rp: true,
    rt: true
  },
  rt: {
    rp: true,
    rt: true
  },
  tbody: {
    tbody: true,
    tfoot: true
  },
  td: {
    td: true,
    th: true
  },
  tfoot: { tbody: true },
  th: {
    td: true,
    th: true
  },
  thead: {
    tbody: true,
    tfoot: true
  },
  tr: { tr: true }
};
function nameChar(g) {
  return g == 45 || g == 46 || g == 58 || g >= 65 && g <= 90 || g == 95 || g >= 97 && g <= 122 || g >= 161;
}
function isSpace(g) {
  return g == 9 || g == 10 || g == 13 || g == 32;
}
var cachedName = null, cachedInput = null, cachedPos = 0;
function tagNameAfter(g, G) {
  let K = g.pos + G;
  if (cachedPos == K && cachedInput == g) return cachedName;
  let q = g.peek(G);
  for (; isSpace(q); ) q = g.peek(++G);
  let J = "";
  for (; nameChar(q); ) J += String.fromCharCode(q), q = g.peek(++G);
  return cachedInput = g, cachedPos = K, cachedName = J ? J.toLowerCase() : q == question || q == bang ? void 0 : null;
}
var lessThan = 60, greaterThan = 62, slash = 47, question = 63, bang = 33, dash = 45;
function ElementContext(g, G) {
  this.name = g, this.parent = G;
}
var startTagTerms = [
  StartTag,
  StartSelfClosingTag,
  StartScriptTag,
  StartStyleTag,
  StartTextareaTag
], elementContext = new ContextTracker({
  start: null,
  shift(g, G, K, q) {
    return startTagTerms.indexOf(G) > -1 ? new ElementContext(tagNameAfter(q, 1) || "", g) : g;
  },
  reduce(g, G) {
    return G == Element && g ? g.parent : g;
  },
  reuse(g, G, K, q) {
    let J = G.type.id;
    return J == StartTag || J == OpenTag ? new ElementContext(tagNameAfter(q, 1) || "", g) : g;
  },
  strict: false
}), tagStart = new ExternalTokenizer((g, G) => {
  if (g.next != lessThan) {
    g.next < 0 && G.context && g.acceptToken(missingCloseTag);
    return;
  }
  g.advance();
  let K = g.next == slash;
  K && g.advance();
  let q = tagNameAfter(g, 0);
  if (q === void 0) return;
  if (!q) return g.acceptToken(K ? IncompleteCloseTag : StartTag);
  let J = G.context ? G.context.name : null;
  if (K) {
    if (q == J) return g.acceptToken(StartCloseTag);
    if (J && implicitlyClosed[J]) return g.acceptToken(missingCloseTag, -2);
    if (G.dialectEnabled(Dialect_noMatch)) return g.acceptToken(NoMatchStartCloseTag);
    for (let g2 = G.context; g2; g2 = g2.parent) if (g2.name == q) return;
    g.acceptToken(MismatchedStartCloseTag);
  } else {
    if (q == "script") return g.acceptToken(StartScriptTag);
    if (q == "style") return g.acceptToken(StartStyleTag);
    if (q == "textarea") return g.acceptToken(StartTextareaTag);
    if (selfClosers$1.hasOwnProperty(q)) return g.acceptToken(StartSelfClosingTag);
    J && closeOnOpen[J] && closeOnOpen[J][q] ? g.acceptToken(missingCloseTag, -1) : g.acceptToken(StartTag);
  }
}, { contextual: true }), commentContent = new ExternalTokenizer((g) => {
  for (let G = 0, K = 0; ; K++) {
    if (g.next < 0) {
      K && g.acceptToken(commentContent$1);
      break;
    }
    if (g.next == dash) G++;
    else if (g.next == greaterThan && G >= 2) {
      K >= 3 && g.acceptToken(commentContent$1, -2);
      break;
    } else G = 0;
    g.advance();
  }
});
function inForeignElement(g) {
  for (; g; g = g.parent) if (g.name == "svg" || g.name == "math") return true;
  return false;
}
var endTag = new ExternalTokenizer((g, G) => {
  if (g.next == slash && g.peek(1) == greaterThan) {
    let K = G.dialectEnabled(Dialect_selfClosing) || inForeignElement(G.context);
    g.acceptToken(K ? SelfClosingEndTag : EndTag, 2);
  } else g.next == greaterThan && g.acceptToken(EndTag, 1);
});
function contentTokenizer(g, G, K) {
  let q = 2 + g.length;
  return new ExternalTokenizer((J) => {
    for (let Y = 0, X = 0, Z = 0; ; Z++) {
      if (J.next < 0) {
        Z && J.acceptToken(G);
        break;
      }
      if (Y == 0 && J.next == lessThan || Y == 1 && J.next == slash || Y >= 2 && Y < q && J.next == g.charCodeAt(Y - 2)) Y++, X++;
      else if ((Y == 2 || Y == q) && isSpace(J.next)) X++;
      else if (Y == q && J.next == greaterThan) {
        Z > X ? J.acceptToken(G, -X) : J.acceptToken(K, -(X - 2));
        break;
      } else if ((J.next == 10 || J.next == 13) && Z) {
        J.acceptToken(G, 1);
        break;
      } else Y = X = 0;
      J.advance();
    }
  });
}
var scriptTokens = contentTokenizer("script", scriptText, StartCloseScriptTag), styleTokens = contentTokenizer("style", styleText, StartCloseStyleTag), textareaTokens = contentTokenizer("textarea", textareaText, StartCloseTextareaTag), htmlHighlighting = styleTags({
  "Text RawText": tags.content,
  "StartTag StartCloseTag SelfClosingEndTag EndTag": tags.angleBracket,
  TagName: tags.tagName,
  "MismatchedCloseTag/TagName": [tags.tagName, tags.invalid],
  AttributeName: tags.attributeName,
  "AttributeValue UnquotedAttributeValue": tags.attributeValue,
  Is: tags.definitionOperator,
  "EntityReference CharacterReference": tags.character,
  Comment: tags.blockComment,
  ProcessingInst: tags.processingInstruction,
  DoctypeDecl: tags.documentMeta
}), parser = LRParser.deserialize({
  version: 14,
  states: ",xOVO!rOOO!WQ#tO'#CqO!]Q#tO'#CzO!bQ#tO'#C}O!gQ#tO'#DQO!lQ#tO'#DSO!qOaO'#CpO!|ObO'#CpO#XOdO'#CpO$eO!rO'#CpOOO`'#Cp'#CpO$lO$fO'#DTO$tQ#tO'#DVO$yQ#tO'#DWOOO`'#Dk'#DkOOO`'#DY'#DYQVO!rOOO%OQ&rO,59]O%ZQ&rO,59fO%fQ&rO,59iO%qQ&rO,59lO%|Q&rO,59nOOOa'#D^'#D^O&XOaO'#CxO&dOaO,59[OOOb'#D_'#D_O&lObO'#C{O&wObO,59[OOOd'#D`'#D`O'POdO'#DOO'[OdO,59[OOO`'#Da'#DaO'dO!rO,59[O'kQ#tO'#DROOO`,59[,59[OOOp'#Db'#DbO'pO$fO,59oOOO`,59o,59oO'xQ#|O,59qO'}Q#|O,59rOOO`-E7W-E7WO(SQ&rO'#CsOOQW'#DZ'#DZO(bQ&rO1G.wOOOa1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Of!lO~Of!mO~OS!nO~Ok!qO!`!oO!b!pO~OS!rO~OS!sO~OS!tO~Oa!uOb!uOc!uO!`!wO!a!uO~Oa!xOb!xOc!xO!b!wO!c!xO~Oa!uOb!uOc!uO!`!{O!a!uO~Oa!xOb!xOc!xO!b!{O!c!xO~OT~bac!dx{!d~",
  goto: "%p!`PPPPPPPPPPPPPPPPPPPP!a!gP!mPP!yP!|#P#S#Y#]#`#f#i#l#r#x!aP!a!aP$O$U$l$r$x%O%U%[%bPPPPPPPP%hX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",
  nodeNames: "\u26A0 StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",
  maxTerm: 67,
  context: elementContext,
  nodeProps: [
    [
      "closedBy",
      -10,
      1,
      2,
      3,
      7,
      8,
      9,
      10,
      11,
      12,
      13,
      "EndTag",
      6,
      "EndTag SelfClosingEndTag",
      -4,
      21,
      30,
      33,
      36,
      "CloseTag"
    ],
    [
      "openedBy",
      4,
      "StartTag StartCloseTag",
      5,
      "StartTag",
      -4,
      29,
      32,
      35,
      37,
      "OpenTag"
    ],
    [
      "group",
      -9,
      14,
      17,
      18,
      19,
      20,
      39,
      40,
      41,
      42,
      "Entity",
      16,
      "Entity TextContent",
      -3,
      28,
      31,
      34,
      "TextContent Entity"
    ],
    [
      "isolate",
      -11,
      21,
      29,
      30,
      32,
      33,
      35,
      36,
      37,
      38,
      41,
      42,
      "ltr",
      -3,
      26,
      27,
      39,
      ""
    ]
  ],
  propSources: [htmlHighlighting],
  skippedNodes: [0],
  repeatNodeCount: 9,
  tokenData: "!<p!aR!YOX$qXY,QYZ,QZ[$q[]&X]^,Q^p$qpq,Qqr-_rs3_sv-_vw3}wxHYx}-_}!OH{!O!P-_!P!Q$q!Q![-_![!]Mz!]!^-_!^!_!$S!_!`!;x!`!a&X!a!c-_!c!}Mz!}#R-_#R#SMz#S#T1k#T#oMz#o#s-_#s$f$q$f%W-_%W%oMz%o%p-_%p&aMz&a&b-_&b1pMz1p4U-_4U4dMz4d4e-_4e$ISMz$IS$I`-_$I`$IbMz$Ib$Kh-_$Kh%#tMz%#t&/x-_&/x&EtMz&Et&FV-_&FV;'SMz;'S;:j!#|;:j;=`3X<%l?&r-_?&r?AhMz?Ah?BY$q?BY?MnMz?MnO$q!Z$|c`PkW!a`!cpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr$qrs&}sv$qvw+Pwx(tx!^$q!^!_*V!_!a&X!a#S$q#S#T&X#T;'S$q;'S;=`+z<%lO$q!R&bX`P!a`!cpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&Xq'UV`P!cpOv&}wx'kx!^&}!^!_(V!_;'S&};'S;=`(n<%lO&}P'pT`POv'kw!^'k!_;'S'k;'S;=`(P<%lO'kP(SP;=`<%l'kp([S!cpOv(Vx;'S(V;'S;=`(h<%lO(Vp(kP;=`<%l(Vq(qP;=`<%l&}a({W`P!a`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t`)jT!a`Or)esv)ew;'S)e;'S;=`)y<%lO)e`)|P;=`<%l)ea*SP;=`<%l(t!Q*^V!a`!cpOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!Q*vP;=`<%l*V!R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%l!6Vq!7]V!cpOv!5kvx!6Vx!`!5k!`!a!7r!a;'S!5k;'S;=`!8V<%lO!5kq!7yS!cpxPOv(Vx;'S(V;'S;=`(h<%lO(Vq!8YP;=`<%l!5ka!8bX!a`Or!8]rs!6Vsv!8]vw!6Vw!a!8]!a!b!8}!b;'S!8];'S;=`!:V<%lO!8]a!9SX!a`Or!8]rs!6Vsv!8]vw!6Vw!`!8]!`!a!9o!a;'S!8];'S;=`!:V<%lO!8]a!9vT!a`xPOr)esv)ew;'S)e;'S;=`)y<%lO)ea!:YP;=`<%l!8]!R!:dY!a`!cpOr!4trs!5ksv!4tvw!6Vwx!8]x!`!4t!`!a!;S!a;'S!4t;'S;=`!;r<%lO!4t!R!;]V!a`!cpxPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!;uP;=`<%l!4t!V!<TXiS`P!a`!cpOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X",
  tokenizers: [
    scriptTokens,
    styleTokens,
    textareaTokens,
    endTag,
    tagStart,
    commentContent,
    0,
    1,
    2,
    3,
    4,
    5
  ],
  topRules: { Document: [0, 15] },
  dialects: {
    noMatch: 0,
    selfClosing: 509
  },
  tokenPrec: 511
});
function getAttrs(g, G) {
  let K = /* @__PURE__ */ Object.create(null);
  for (let q of g.getChildren(Attribute)) {
    let g2 = q.getChild(AttributeName), J = q.getChild(AttributeValue) || q.getChild(UnquotedAttributeValue);
    g2 && (K[G.read(g2.from, g2.to)] = J ? J.type.id == AttributeValue ? G.read(J.from + 1, J.to - 1) : G.read(J.from, J.to) : "");
  }
  return K;
}
function findTagName(g, G) {
  let K = g.getChild(TagName);
  return K ? G.read(K.from, K.to) : " ";
}
function maybeNest(g, G, K) {
  let q;
  for (let J of K) if (!J.attrs || J.attrs(q || (q = getAttrs(g.node.parent.firstChild, G)))) return { parser: J.parser };
  return null;
}
function configureNesting(g = [], G = []) {
  let K = [], J = [], Y = [], X = [];
  for (let G2 of g) (G2.tag == "script" ? K : G2.tag == "style" ? J : G2.tag == "textarea" ? Y : X).push(G2);
  let Z = G.length ? /* @__PURE__ */ Object.create(null) : null;
  for (let g2 of G) (Z[g2.name] || (Z[g2.name] = [])).push(g2);
  return parseMixed((g2, G2) => {
    let q = g2.type.id;
    if (q == ScriptText) return maybeNest(g2, G2, K);
    if (q == StyleText) return maybeNest(g2, G2, J);
    if (q == TextareaText) return maybeNest(g2, G2, Y);
    if (q == Element && X.length) {
      let K2 = g2.node, q2 = K2.firstChild, J2 = q2 && findTagName(q2, G2), Y2;
      if (J2) {
        for (let g3 of X) if (g3.tag == J2 && (!g3.attrs || g3.attrs(Y2 || (Y2 = getAttrs(q2, G2))))) {
          let G3 = K2.lastChild, J3 = G3.type.id == CloseTag ? G3.from : K2.to;
          if (J3 > q2.to) return {
            parser: g3.parser,
            overlay: [{
              from: q2.to,
              to: J3
            }]
          };
        }
      }
    }
    if (Z && q == Attribute) {
      let K2 = g2.node, q2;
      if (q2 = K2.firstChild) {
        let g3 = Z[G2.read(q2.from, q2.to)];
        if (g3) for (let q3 of g3) {
          if (q3.tagName && q3.tagName != findTagName(K2.parent, G2)) continue;
          let g4 = K2.lastChild;
          if (g4.type.id == AttributeValue) {
            let G3 = g4.from + 1, K3 = g4.lastChild, J2 = g4.to - (K3 && K3.isError ? 0 : 1);
            if (J2 > G3) return {
              parser: q3.parser,
              overlay: [{
                from: G3,
                to: J2
              }]
            };
          } else if (g4.type.id == UnquotedAttributeValue) return {
            parser: q3.parser,
            overlay: [{
              from: g4.from,
              to: g4.to
            }]
          };
        }
      }
    }
    return null;
  });
}
var Targets = [
  "_blank",
  "_self",
  "_top",
  "_parent"
], Charsets = [
  "ascii",
  "utf-8",
  "utf-16",
  "latin1",
  "latin1"
], Methods = [
  "get",
  "post",
  "put",
  "delete"
], Encs = [
  "application/x-www-form-urlencoded",
  "multipart/form-data",
  "text/plain"
], Bool = ["true", "false"], S = {}, Tags = {
  a: { attrs: {
    href: null,
    ping: null,
    type: null,
    media: null,
    target: Targets,
    hreflang: null
  } },
  abbr: S,
  address: S,
  area: { attrs: {
    alt: null,
    coords: null,
    href: null,
    target: null,
    ping: null,
    media: null,
    hreflang: null,
    type: null,
    shape: [
      "default",
      "rect",
      "circle",
      "poly"
    ]
  } },
  article: S,
  aside: S,
  audio: { attrs: {
    src: null,
    mediagroup: null,
    crossorigin: ["anonymous", "use-credentials"],
    preload: [
      "none",
      "metadata",
      "auto"
    ],
    autoplay: ["autoplay"],
    loop: ["loop"],
    controls: ["controls"]
  } },
  b: S,
  base: { attrs: {
    href: null,
    target: Targets
  } },
  bdi: S,
  bdo: S,
  blockquote: { attrs: { cite: null } },
  body: S,
  br: S,
  button: { attrs: {
    form: null,
    formaction: null,
    name: null,
    value: null,
    autofocus: ["autofocus"],
    disabled: ["autofocus"],
    formenctype: Encs,
    formmethod: Methods,
    formnovalidate: ["novalidate"],
    formtarget: Targets,
    type: [
      "submit",
      "reset",
      "button"
    ]
  } },
  canvas: { attrs: {
    width: null,
    height: null
  } },
  caption: S,
  center: S,
  cite: S,
  code: S,
  col: { attrs: { span: null } },
  colgroup: { attrs: { span: null } },
  command: { attrs: {
    type: [
      "command",
      "checkbox",
      "radio"
    ],
    label: null,
    icon: null,
    radiogroup: null,
    command: null,
    title: null,
    disabled: ["disabled"],
    checked: ["checked"]
  } },
  data: { attrs: { value: null } },
  datagrid: { attrs: {
    disabled: ["disabled"],
    multiple: ["multiple"]
  } },
  datalist: { attrs: { data: null } },
  dd: S,
  del: { attrs: {
    cite: null,
    datetime: null
  } },
  details: { attrs: { open: ["open"] } },
  dfn: S,
  div: S,
  dl: S,
  dt: S,
  em: S,
  embed: { attrs: {
    src: null,
    type: null,
    width: null,
    height: null
  } },
  eventsource: { attrs: { src: null } },
  fieldset: { attrs: {
    disabled: ["disabled"],
    form: null,
    name: null
  } },
  figcaption: S,
  figure: S,
  footer: S,
  form: { attrs: {
    action: null,
    name: null,
    "accept-charset": Charsets,
    autocomplete: ["on", "off"],
    enctype: Encs,
    method: Methods,
    novalidate: ["novalidate"],
    target: Targets
  } },
  h1: S,
  h2: S,
  h3: S,
  h4: S,
  h5: S,
  h6: S,
  head: { children: [
    "title",
    "base",
    "link",
    "style",
    "meta",
    "script",
    "noscript",
    "command"
  ] },
  header: S,
  hgroup: S,
  hr: S,
  html: { attrs: { manifest: null } },
  i: S,
  iframe: { attrs: {
    src: null,
    srcdoc: null,
    name: null,
    width: null,
    height: null,
    sandbox: [
      "allow-top-navigation",
      "allow-same-origin",
      "allow-forms",
      "allow-scripts"
    ],
    seamless: ["seamless"]
  } },
  img: { attrs: {
    alt: null,
    src: null,
    ismap: null,
    usemap: null,
    width: null,
    height: null,
    crossorigin: ["anonymous", "use-credentials"]
  } },
  input: { attrs: {
    alt: null,
    dirname: null,
    form: null,
    formaction: null,
    height: null,
    list: null,
    max: null,
    maxlength: null,
    min: null,
    name: null,
    pattern: null,
    placeholder: null,
    size: null,
    src: null,
    step: null,
    value: null,
    width: null,
    accept: [
      "audio/*",
      "video/*",
      "image/*"
    ],
    autocomplete: ["on", "off"],
    autofocus: ["autofocus"],
    checked: ["checked"],
    disabled: ["disabled"],
    formenctype: Encs,
    formmethod: Methods,
    formnovalidate: ["novalidate"],
    formtarget: Targets,
    multiple: ["multiple"],
    readonly: ["readonly"],
    required: ["required"],
    type: [
      "hidden",
      "text",
      "search",
      "tel",
      "url",
      "email",
      "password",
      "datetime",
      "date",
      "month",
      "week",
      "time",
      "datetime-local",
      "number",
      "range",
      "color",
      "checkbox",
      "radio",
      "file",
      "submit",
      "image",
      "reset",
      "button"
    ]
  } },
  ins: { attrs: {
    cite: null,
    datetime: null
  } },
  kbd: S,
  keygen: { attrs: {
    challenge: null,
    form: null,
    name: null,
    autofocus: ["autofocus"],
    disabled: ["disabled"],
    keytype: ["RSA"]
  } },
  label: { attrs: {
    for: null,
    form: null
  } },
  legend: S,
  li: { attrs: { value: null } },
  link: { attrs: {
    href: null,
    type: null,
    hreflang: null,
    media: null,
    sizes: [
      "all",
      "16x16",
      "16x16 32x32",
      "16x16 32x32 64x64"
    ]
  } },
  map: { attrs: { name: null } },
  mark: S,
  menu: { attrs: {
    label: null,
    type: [
      "list",
      "context",
      "toolbar"
    ]
  } },
  meta: { attrs: {
    content: null,
    charset: Charsets,
    name: [
      "viewport",
      "application-name",
      "author",
      "description",
      "generator",
      "keywords"
    ],
    "http-equiv": [
      "content-language",
      "content-type",
      "default-style",
      "refresh"
    ]
  } },
  meter: { attrs: {
    value: null,
    min: null,
    low: null,
    high: null,
    max: null,
    optimum: null
  } },
  nav: S,
  noscript: S,
  object: { attrs: {
    data: null,
    type: null,
    name: null,
    usemap: null,
    form: null,
    width: null,
    height: null,
    typemustmatch: ["typemustmatch"]
  } },
  ol: {
    attrs: {
      reversed: ["reversed"],
      start: null,
      type: [
        "1",
        "a",
        "A",
        "i",
        "I"
      ]
    },
    children: [
      "li",
      "script",
      "template",
      "ul",
      "ol"
    ]
  },
  optgroup: { attrs: {
    disabled: ["disabled"],
    label: null
  } },
  option: { attrs: {
    disabled: ["disabled"],
    label: null,
    selected: ["selected"],
    value: null
  } },
  output: { attrs: {
    for: null,
    form: null,
    name: null
  } },
  p: S,
  param: { attrs: {
    name: null,
    value: null
  } },
  pre: S,
  progress: { attrs: {
    value: null,
    max: null
  } },
  q: { attrs: { cite: null } },
  rp: S,
  rt: S,
  ruby: S,
  samp: S,
  script: { attrs: {
    type: ["text/javascript"],
    src: null,
    async: ["async"],
    defer: ["defer"],
    charset: Charsets
  } },
  section: S,
  select: { attrs: {
    form: null,
    name: null,
    size: null,
    autofocus: ["autofocus"],
    disabled: ["disabled"],
    multiple: ["multiple"]
  } },
  slot: { attrs: { name: null } },
  small: S,
  source: { attrs: {
    src: null,
    type: null,
    media: null
  } },
  span: S,
  strong: S,
  style: { attrs: {
    type: ["text/css"],
    media: null,
    scoped: null
  } },
  sub: S,
  summary: S,
  sup: S,
  table: S,
  tbody: S,
  td: { attrs: {
    colspan: null,
    rowspan: null,
    headers: null
  } },
  template: S,
  textarea: { attrs: {
    dirname: null,
    form: null,
    maxlength: null,
    name: null,
    placeholder: null,
    rows: null,
    cols: null,
    autofocus: ["autofocus"],
    disabled: ["disabled"],
    readonly: ["readonly"],
    required: ["required"],
    wrap: ["soft", "hard"]
  } },
  tfoot: S,
  th: { attrs: {
    colspan: null,
    rowspan: null,
    headers: null,
    scope: [
      "row",
      "col",
      "rowgroup",
      "colgroup"
    ]
  } },
  thead: S,
  time: { attrs: { datetime: null } },
  title: S,
  tr: S,
  track: { attrs: {
    src: null,
    label: null,
    default: null,
    kind: [
      "subtitles",
      "captions",
      "descriptions",
      "chapters",
      "metadata"
    ],
    srclang: null
  } },
  ul: { children: [
    "li",
    "script",
    "template",
    "ul",
    "ol"
  ] },
  var: S,
  video: { attrs: {
    src: null,
    poster: null,
    width: null,
    height: null,
    crossorigin: ["anonymous", "use-credentials"],
    preload: [
      "auto",
      "metadata",
      "none"
    ],
    autoplay: ["autoplay"],
    mediagroup: ["movie"],
    muted: ["muted"],
    controls: ["controls"]
  } },
  wbr: S
}, GlobalAttrs = {
  accesskey: null,
  class: null,
  contenteditable: Bool,
  contextmenu: null,
  dir: [
    "ltr",
    "rtl",
    "auto"
  ],
  draggable: [
    "true",
    "false",
    "auto"
  ],
  dropzone: [
    "copy",
    "move",
    "link",
    "string:",
    "file:"
  ],
  hidden: ["hidden"],
  id: null,
  inert: ["inert"],
  itemid: null,
  itemprop: null,
  itemref: null,
  itemscope: ["itemscope"],
  itemtype: null,
  lang: [
    "ar",
    "bn",
    "de",
    "en-GB",
    "en-US",
    "es",
    "fr",
    "hi",
    "id",
    "ja",
    "pa",
    "pt",
    "ru",
    "tr",
    "zh"
  ],
  spellcheck: Bool,
  autocorrect: Bool,
  autocapitalize: Bool,
  style: null,
  tabindex: null,
  title: null,
  translate: ["yes", "no"],
  rel: [
    "stylesheet",
    "alternate",
    "author",
    "bookmark",
    "help",
    "license",
    "next",
    "nofollow",
    "noreferrer",
    "prefetch",
    "prev",
    "search",
    "tag"
  ],
  role: /* @__PURE__ */ "alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),
  "aria-activedescendant": null,
  "aria-atomic": Bool,
  "aria-autocomplete": [
    "inline",
    "list",
    "both",
    "none"
  ],
  "aria-busy": Bool,
  "aria-checked": [
    "true",
    "false",
    "mixed",
    "undefined"
  ],
  "aria-controls": null,
  "aria-describedby": null,
  "aria-disabled": Bool,
  "aria-dropeffect": null,
  "aria-expanded": [
    "true",
    "false",
    "undefined"
  ],
  "aria-flowto": null,
  "aria-grabbed": [
    "true",
    "false",
    "undefined"
  ],
  "aria-haspopup": Bool,
  "aria-hidden": Bool,
  "aria-invalid": [
    "true",
    "false",
    "grammar",
    "spelling"
  ],
  "aria-label": null,
  "aria-labelledby": null,
  "aria-level": null,
  "aria-live": [
    "off",
    "polite",
    "assertive"
  ],
  "aria-multiline": Bool,
  "aria-multiselectable": Bool,
  "aria-owns": null,
  "aria-posinset": null,
  "aria-pressed": [
    "true",
    "false",
    "mixed",
    "undefined"
  ],
  "aria-readonly": Bool,
  "aria-relevant": null,
  "aria-required": Bool,
  "aria-selected": [
    "true",
    "false",
    "undefined"
  ],
  "aria-setsize": null,
  "aria-sort": [
    "ascending",
    "descending",
    "none",
    "other"
  ],
  "aria-valuemax": null,
  "aria-valuemin": null,
  "aria-valuenow": null,
  "aria-valuetext": null
}, eventAttributes = /* @__PURE__ */ "beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map((g) => "on" + g);
for (let g of eventAttributes) GlobalAttrs[g] = null;
var Schema = class {
  constructor(g, G) {
    this.tags = Object.assign(Object.assign({}, Tags), g), this.globalAttrs = Object.assign(Object.assign({}, GlobalAttrs), G), this.allTags = Object.keys(this.tags), this.globalAttrNames = Object.keys(this.globalAttrs);
  }
};
Schema.default = /* @__PURE__ */ new Schema();
function elementName(g, G, K = g.length) {
  if (!G) return "";
  let q = G.firstChild, J = q && q.getChild("TagName");
  return J ? g.sliceString(J.from, Math.min(J.to, K)) : "";
}
function findParentElement(g, G = false) {
  for (; g; g = g.parent) if (g.name == "Element") if (G) G = false;
  else return g;
  return null;
}
function allowedChildren(g, G, K) {
  var _a;
  return ((_a = K.tags[elementName(g, findParentElement(G))]) == null ? void 0 : _a.children) || K.allTags;
}
function openTags(g, G) {
  let K = [];
  for (let q = findParentElement(G); q && !q.type.isTop; q = findParentElement(q.parent)) {
    let J = elementName(g, q);
    if (J && q.lastChild.name == "CloseTag") break;
    J && K.indexOf(J) < 0 && (G.name == "EndTag" || G.from >= q.firstChild.to) && K.push(J);
  }
  return K;
}
var identifier = /^[:\-\.\w\u00b7-\uffff]*$/;
function completeTag(g, G, K, q, J) {
  let Y = /\s*>/.test(g.sliceDoc(J, J + 5)) ? "" : ">", X = findParentElement(K, true);
  return {
    from: q,
    to: J,
    options: allowedChildren(g.doc, X, G).map((g2) => ({
      label: g2,
      type: "type"
    })).concat(openTags(g.doc, K).map((g2, G2) => ({
      label: "/" + g2,
      apply: "/" + g2 + Y,
      type: "type",
      boost: 99 - G2
    }))),
    validFor: /^\/?[:\-\.\w\u00b7-\uffff]*$/
  };
}
function completeCloseTag(g, G, K, q) {
  let J = /\s*>/.test(g.sliceDoc(q, q + 5)) ? "" : ">";
  return {
    from: K,
    to: q,
    options: openTags(g.doc, G).map((g2, G2) => ({
      label: g2,
      apply: g2 + J,
      type: "type",
      boost: 99 - G2
    })),
    validFor: identifier
  };
}
function completeStartTag(g, G, K, q) {
  let J = [], Y = 0;
  for (let q2 of allowedChildren(g.doc, K, G)) J.push({
    label: "<" + q2,
    type: "type"
  });
  for (let G2 of openTags(g.doc, K)) J.push({
    label: "</" + G2 + ">",
    type: "type",
    boost: 99 - Y++
  });
  return {
    from: q,
    to: q,
    options: J,
    validFor: /^<\/?[:\-\.\w\u00b7-\uffff]*$/
  };
}
function completeAttrName(g, G, K, q, J) {
  let Y = findParentElement(K), X = Y ? G.tags[elementName(g.doc, Y)] : null, Z = X && X.attrs ? Object.keys(X.attrs) : [];
  return {
    from: q,
    to: J,
    options: (X && X.globalAttrs === false ? Z : Z.length ? Z.concat(G.globalAttrNames) : G.globalAttrNames).map((g2) => ({
      label: g2,
      type: "property"
    })),
    validFor: identifier
  };
}
function completeAttrValue(g, G, K, q, J) {
  var _a;
  let Y = (_a = K.parent) == null ? void 0 : _a.getChild("AttributeName"), X = [], Z;
  if (Y) {
    let Q = g.sliceDoc(Y.from, Y.to), $ = G.globalAttrs[Q];
    if (!$) {
      let q2 = findParentElement(K), J2 = q2 ? G.tags[elementName(g.doc, q2)] : null;
      $ = (J2 == null ? void 0 : J2.attrs) && J2.attrs[Q];
    }
    if ($) {
      let G2 = g.sliceDoc(q, J).toLowerCase(), K2 = '"', Y2 = '"';
      /^['"]/.test(G2) ? (Z = G2[0] == '"' ? /^[^"]*$/ : /^[^']*$/, K2 = "", Y2 = g.sliceDoc(J, J + 1) == G2[0] ? "" : G2[0], G2 = G2.slice(1), q++) : Z = /^[^\s<>='"]*$/;
      for (let g2 of $) X.push({
        label: g2,
        apply: K2 + g2 + Y2,
        type: "constant"
      });
    }
  }
  return {
    from: q,
    to: J,
    options: X,
    validFor: Z
  };
}
function htmlCompletionFor(g, G) {
  let { state: q, pos: J } = G, Y = syntaxTree(q).resolveInner(J, -1), X = Y.resolve(J);
  for (let g2 = J, G2; X == Y && (G2 = Y.childBefore(g2)); ) {
    let K = G2.lastChild;
    if (!K || !K.type.isError || K.from < K.to) break;
    X = Y = G2, g2 = K.from;
  }
  return Y.name == "TagName" ? Y.parent && /CloseTag$/.test(Y.parent.name) ? completeCloseTag(q, Y, Y.from, J) : completeTag(q, g, Y, Y.from, J) : Y.name == "StartTag" ? completeTag(q, g, Y, J, J) : Y.name == "StartCloseTag" || Y.name == "IncompleteCloseTag" ? completeCloseTag(q, Y, J, J) : Y.name == "OpenTag" || Y.name == "SelfClosingTag" || Y.name == "AttributeName" ? completeAttrName(q, g, Y, Y.name == "AttributeName" ? Y.from : J, J) : Y.name == "Is" || Y.name == "AttributeValue" || Y.name == "UnquotedAttributeValue" ? completeAttrValue(q, g, Y, Y.name == "Is" ? J : Y.from, J) : G.explicit && (X.name == "Element" || X.name == "Text" || X.name == "Document") ? completeStartTag(q, g, Y, J) : null;
}
function htmlCompletionSource(g) {
  return htmlCompletionFor(Schema.default, g);
}
function htmlCompletionSourceWith(g) {
  let { extraTags: G, extraGlobalAttributes: K } = g, q = K || G ? new Schema(G, K) : Schema.default;
  return (g2) => htmlCompletionFor(q, g2);
}
var jsonParser = /* @__PURE__ */ javascriptLanguage.parser.configure({ top: "SingleExpression" }), defaultNesting = [
  {
    tag: "script",
    attrs: (g) => g.type == "text/typescript" || g.lang == "ts",
    parser: typescriptLanguage.parser
  },
  {
    tag: "script",
    attrs: (g) => g.type == "text/babel" || g.type == "text/jsx",
    parser: jsxLanguage.parser
  },
  {
    tag: "script",
    attrs: (g) => g.type == "text/typescript-jsx",
    parser: tsxLanguage.parser
  },
  {
    tag: "script",
    attrs(g) {
      return /^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(g.type);
    },
    parser: jsonParser
  },
  {
    tag: "script",
    attrs(g) {
      return !g.type || /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(g.type);
    },
    parser: javascriptLanguage.parser
  },
  {
    tag: "style",
    attrs(g) {
      return (!g.lang || g.lang == "css") && (!g.type || /^(text\/)?(x-)?(stylesheet|css)$/i.test(g.type));
    },
    parser: cssLanguage.parser
  }
], defaultAttrs = /* @__PURE__ */ [{
  name: "style",
  parser: /* @__PURE__ */ cssLanguage.parser.configure({ top: "Styles" })
}].concat(/* @__PURE__ */ eventAttributes.map((g) => ({
  name: g,
  parser: javascriptLanguage.parser
}))), htmlPlain = /* @__PURE__ */ LRLanguage.define({
  name: "html",
  parser: /* @__PURE__ */ parser.configure({ props: [
    /* @__PURE__ */ indentNodeProp.add({
      Element(g) {
        let G = /^(\s*)(<\/)?/.exec(g.textAfter);
        return g.node.to <= g.pos + G[0].length ? g.continue() : g.lineIndent(g.node.from) + (G[2] ? 0 : g.unit);
      },
      "OpenTag CloseTag SelfClosingTag"(g) {
        return g.column(g.node.from) + g.unit;
      },
      Document(g) {
        if (g.pos + /\s*/.exec(g.textAfter)[0].length < g.node.to) return g.continue();
        let G = null, K;
        for (let K2 = g.node; ; ) {
          let g2 = K2.lastChild;
          if (!g2 || g2.name != "Element" || g2.to != K2.to) break;
          G = K2 = g2;
        }
        return G && !((K = G.lastChild) && (K.name == "CloseTag" || K.name == "SelfClosingTag")) ? g.lineIndent(G.from) + g.unit : null;
      }
    }),
    /* @__PURE__ */ foldNodeProp.add({ Element(g) {
      let G = g.firstChild, K = g.lastChild;
      return !G || G.name != "OpenTag" ? null : {
        from: G.to,
        to: K.name == "CloseTag" ? K.from : g.to
      };
    } }),
    /* @__PURE__ */ bracketMatchingHandle.add({ "OpenTag CloseTag": (g) => g.getChild("TagName") })
  ] }),
  languageData: {
    commentTokens: { block: {
      open: "<!--",
      close: "-->"
    } },
    indentOnInput: /^\s*<\/\w+\W$/,
    wordChars: "-._"
  }
}), htmlLanguage = /* @__PURE__ */ htmlPlain.configure({ wrap: /* @__PURE__ */ configureNesting(defaultNesting, defaultAttrs) });
function html(g = {}) {
  let G = "", K;
  return g.matchClosingTags === false && (G = "noMatch"), g.selfClosingTags === true && (G = (G ? G + " " : "") + "selfClosing"), (g.nestedLanguages && g.nestedLanguages.length || g.nestedAttributes && g.nestedAttributes.length) && (K = configureNesting((g.nestedLanguages || []).concat(defaultNesting), (g.nestedAttributes || []).concat(defaultAttrs))), new LanguageSupport(K ? htmlPlain.configure({
    wrap: K,
    dialect: G
  }) : G ? htmlLanguage.configure({ dialect: G }) : htmlLanguage, [
    htmlLanguage.data.of({ autocomplete: htmlCompletionSourceWith(g) }),
    g.autoCloseTags === false ? [] : autoCloseTags,
    javascript().support,
    css().support
  ]);
}
var selfClosers = /* @__PURE__ */ new Set(/* @__PURE__ */ "area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")), autoCloseTags = /* @__PURE__ */ EditorView.inputHandler.of((g, q, J, Y, X) => {
  if (g.composing || g.state.readOnly || q != J || Y != ">" && Y != "/" || !htmlLanguage.isActiveAt(g.state, q, -1)) return false;
  let Z = X(), { state: Q } = Z, $ = Q.changeByRange((g2) => {
    var _a, _b, _c;
    let q2 = Q.doc.sliceString(g2.from - 1, g2.to) == Y, { head: J2 } = g2, X2 = syntaxTree(Q).resolveInner(J2, -1), Z2;
    if (q2 && Y == ">" && X2.name == "EndTag") {
      let G = X2.parent;
      if (((_b = (_a = G.parent) == null ? void 0 : _a.lastChild) == null ? void 0 : _b.name) != "CloseTag" && (Z2 = elementName(Q.doc, G.parent, J2)) && !selfClosers.has(Z2)) return {
        range: g2,
        changes: {
          from: J2,
          to: J2 + (Q.doc.sliceString(J2, J2 + 1) === ">" ? 1 : 0),
          insert: `</${Z2}>`
        }
      };
    } else if (q2 && Y == "/" && X2.name == "IncompleteCloseTag") {
      let g3 = X2.parent;
      if (X2.from == J2 - 2 && ((_c = g3.lastChild) == null ? void 0 : _c.name) != "CloseTag" && (Z2 = elementName(Q.doc, g3, J2)) && !selfClosers.has(Z2)) {
        let g4 = J2 + (Q.doc.sliceString(J2, J2 + 1) === ">" ? 1 : 0), K = `${Z2}>`;
        return {
          range: EditorSelection.cursor(J2 + K.length, -1),
          changes: {
            from: J2,
            to: g4,
            insert: K
          }
        };
      }
    }
    return { range: g2 };
  });
  return $.changes.empty ? false : (g.dispatch([Z, Q.update($, {
    userEvent: "input.complete",
    scrollIntoView: true
  })]), true);
});
export {
  htmlLanguage as a,
  htmlCompletionSourceWith as i,
  html as n,
  htmlPlain as o,
  htmlCompletionSource as r,
  autoCloseTags as t
};
