var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var _a, _b;
import { r as e } from "./rolldown-runtime-CMxvf4Kt.js";
import { n as t, t as n } from "./dist-Cjo54wyf.js";
import { n as r, t as i } from "./dist-CxnnVdIg.js";
var a = class extends Error {
  constructor(e12) {
    super(e12), this.name = `ShikiError`;
  }
};
i();
function o(e12) {
  return s(e12);
}
function s(e12) {
  return Array.isArray(e12) ? c(e12) : e12 instanceof RegExp ? e12 : typeof e12 == `object` ? l(e12) : e12;
}
function c(e12) {
  let t2 = [];
  for (let n2 = 0, r2 = e12.length; n2 < r2; n2++) t2[n2] = s(e12[n2]);
  return t2;
}
function l(e12) {
  let t2 = {};
  for (let n2 in e12) t2[n2] = s(e12[n2]);
  return t2;
}
function u(e12, ...t2) {
  return t2.forEach((t3) => {
    for (let n2 in t3) e12[n2] = t3[n2];
  }), e12;
}
function d(e12) {
  let t2 = ~e12.lastIndexOf(`/`) || ~e12.lastIndexOf(`\\`);
  return t2 === 0 ? e12 : ~t2 === e12.length - 1 ? d(e12.substring(0, e12.length - 1)) : e12.substr(~t2 + 1);
}
var f = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/g, p = class {
  static hasCaptures(e12) {
    return e12 === null ? false : (f.lastIndex = 0, f.test(e12));
  }
  static replaceCaptures(e12, t2, n2) {
    return e12.replace(f, (e13, r2, i2, a2) => {
      let o2 = n2[parseInt(r2 || i2, 10)];
      if (o2) {
        let e14 = t2.substring(o2.start, o2.end);
        for (; e14[0] === `.`; ) e14 = e14.substring(1);
        switch (a2) {
          case `downcase`:
            return e14.toLowerCase();
          case `upcase`:
            return e14.toUpperCase();
          default:
            return e14;
        }
      } else return e13;
    });
  }
};
function m(e12, t2) {
  return e12 < t2 ? -1 : +(e12 > t2);
}
function h(e12, t2) {
  if (e12 === null && t2 === null) return 0;
  if (!e12) return -1;
  if (!t2) return 1;
  let n2 = e12.length, r2 = t2.length;
  if (n2 === r2) {
    for (let r3 = 0; r3 < n2; r3++) {
      let n3 = m(e12[r3], t2[r3]);
      if (n3 !== 0) return n3;
    }
    return 0;
  }
  return n2 - r2;
}
function g(e12) {
  return !!(/^#[0-9a-f]{6}$/i.test(e12) || /^#[0-9a-f]{8}$/i.test(e12) || /^#[0-9a-f]{3}$/i.test(e12) || /^#[0-9a-f]{4}$/i.test(e12));
}
function _(e12) {
  return e12.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, `\\$&`);
}
var v = class {
  constructor(e12) {
    __publicField(this, "cache", /* @__PURE__ */ new Map());
    this.fn = e12;
  }
  get(e12) {
    if (this.cache.has(e12)) return this.cache.get(e12);
    let t2 = this.fn(e12);
    return this.cache.set(e12, t2), t2;
  }
}, y = class {
  constructor(e12, t2, n2) {
    __publicField(this, "_cachedMatchRoot", new v((e12) => this._root.match(e12)));
    this._colorMap = e12, this._defaults = t2, this._root = n2;
  }
  static createFromRawTheme(e12, t2) {
    return this.createFromParsedTheme(ie(e12), t2);
  }
  static createFromParsedTheme(e12, t2) {
    return oe(e12, t2);
  }
  getColorMap() {
    return this._colorMap.getColorMap();
  }
  getDefaults() {
    return this._defaults;
  }
  match(e12) {
    if (e12 === null) return this._defaults;
    let t2 = e12.scopeName, n2 = this._cachedMatchRoot.get(t2).find((t3) => te(e12.parent, t3.parentScopes));
    return n2 ? new re(n2.fontStyle, n2.foreground, n2.background) : null;
  }
}, ee = class e2 {
  constructor(e12, t2) {
    this.parent = e12, this.scopeName = t2;
  }
  static push(t2, n2) {
    for (let r2 of n2) t2 = new e2(t2, r2);
    return t2;
  }
  static from(...t2) {
    let n2 = null;
    for (let r2 = 0; r2 < t2.length; r2++) n2 = new e2(n2, t2[r2]);
    return n2;
  }
  push(t2) {
    return new e2(this, t2);
  }
  getSegments() {
    let e12 = this, t2 = [];
    for (; e12; ) t2.push(e12.scopeName), e12 = e12.parent;
    return t2.reverse(), t2;
  }
  toString() {
    return this.getSegments().join(` `);
  }
  extends(e12) {
    return this === e12 ? true : this.parent === null ? false : this.parent.extends(e12);
  }
  getExtensionIfDefined(e12) {
    let t2 = [], n2 = this;
    for (; n2 && n2 !== e12; ) t2.push(n2.scopeName), n2 = n2.parent;
    return n2 === e12 ? t2.reverse() : void 0;
  }
};
function te(e12, t2) {
  if (t2.length === 0) return true;
  for (let n2 = 0; n2 < t2.length; n2++) {
    let r2 = t2[n2], i2 = false;
    if (r2 === `>`) {
      if (n2 === t2.length - 1) return false;
      r2 = t2[++n2], i2 = true;
    }
    for (; e12 && !ne(e12.scopeName, r2); ) {
      if (i2) return false;
      e12 = e12.parent;
    }
    if (!e12) return false;
    e12 = e12.parent;
  }
  return true;
}
function ne(e12, t2) {
  return t2 === e12 || e12.startsWith(t2) && e12[t2.length] === `.`;
}
var re = class {
  constructor(e12, t2, n2) {
    this.fontStyle = e12, this.foregroundId = t2, this.backgroundId = n2;
  }
};
function ie(e12) {
  if (!e12 || !e12.settings || !Array.isArray(e12.settings)) return [];
  let t2 = e12.settings, n2 = [], r2 = 0;
  for (let e13 = 0, i2 = t2.length; e13 < i2; e13++) {
    let i3 = t2[e13];
    if (!i3.settings) continue;
    let a2;
    if (typeof i3.scope == `string`) {
      let e14 = i3.scope;
      e14 = e14.replace(/^[,]+/, ``), e14 = e14.replace(/[,]+$/, ``), a2 = e14.split(`,`);
    } else a2 = Array.isArray(i3.scope) ? i3.scope : [``];
    let o2 = -1;
    if (typeof i3.settings.fontStyle == `string`) {
      o2 = 0;
      let e14 = i3.settings.fontStyle.split(` `);
      for (let t3 = 0, n3 = e14.length; t3 < n3; t3++) switch (e14[t3]) {
        case `italic`:
          o2 |= 1;
          break;
        case `bold`:
          o2 |= 2;
          break;
        case `underline`:
          o2 |= 4;
          break;
        case `strikethrough`:
          o2 |= 8;
          break;
      }
    }
    let s2 = null;
    typeof i3.settings.foreground == `string` && g(i3.settings.foreground) && (s2 = i3.settings.foreground);
    let c2 = null;
    typeof i3.settings.background == `string` && g(i3.settings.background) && (c2 = i3.settings.background);
    for (let t3 = 0, i4 = a2.length; t3 < i4; t3++) {
      let i5 = a2[t3].trim().split(` `), l2 = i5[i5.length - 1], u2 = null;
      i5.length > 1 && (u2 = i5.slice(0, i5.length - 1), u2.reverse()), n2[r2++] = new ae(l2, u2, e13, o2, s2, c2);
    }
  }
  return n2;
}
var ae = class {
  constructor(e12, t2, n2, r2, i2, a2) {
    this.scope = e12, this.parentScopes = t2, this.index = n2, this.fontStyle = r2, this.foreground = i2, this.background = a2;
  }
}, b = ((e12) => (e12[e12.NotSet = -1] = `NotSet`, e12[e12.None = 0] = `None`, e12[e12.Italic = 1] = `Italic`, e12[e12.Bold = 2] = `Bold`, e12[e12.Underline = 4] = `Underline`, e12[e12.Strikethrough = 8] = `Strikethrough`, e12))(b || {});
function oe(e12, t2) {
  e12.sort((e13, t3) => {
    let n3 = m(e13.scope, t3.scope);
    return n3 !== 0 || (n3 = h(e13.parentScopes, t3.parentScopes), n3 !== 0) ? n3 : e13.index - t3.index;
  });
  let n2 = 0, r2 = `#000000`, i2 = `#ffffff`;
  for (; e12.length >= 1 && e12[0].scope === ``; ) {
    let t3 = e12.shift();
    t3.fontStyle !== -1 && (n2 = t3.fontStyle), t3.foreground !== null && (r2 = t3.foreground), t3.background !== null && (i2 = t3.background);
  }
  let a2 = new se(t2), o2 = new re(n2, a2.getId(r2), a2.getId(i2)), s2 = new ue(new le(0, null, -1, 0, 0), []);
  for (let t3 = 0, n3 = e12.length; t3 < n3; t3++) {
    let n4 = e12[t3];
    s2.insert(0, n4.scope, n4.parentScopes, n4.fontStyle, a2.getId(n4.foreground), a2.getId(n4.background));
  }
  return new y(a2, o2, s2);
}
var se = class {
  constructor(e12) {
    __publicField(this, "_isFrozen");
    __publicField(this, "_lastColorId");
    __publicField(this, "_id2color");
    __publicField(this, "_color2id");
    if (this._lastColorId = 0, this._id2color = [], this._color2id = /* @__PURE__ */ Object.create(null), Array.isArray(e12)) {
      this._isFrozen = true;
      for (let t2 = 0, n2 = e12.length; t2 < n2; t2++) this._color2id[e12[t2]] = t2, this._id2color[t2] = e12[t2];
    } else this._isFrozen = false;
  }
  getId(e12) {
    if (e12 === null) return 0;
    e12 = e12.toUpperCase();
    let t2 = this._color2id[e12];
    if (t2) return t2;
    if (this._isFrozen) throw Error(`Missing color in color map - ${e12}`);
    return t2 = ++this._lastColorId, this._color2id[e12] = t2, this._id2color[t2] = e12, t2;
  }
  getColorMap() {
    return this._id2color.slice(0);
  }
}, ce = Object.freeze([]), le = class e3 {
  constructor(e12, t2, n2, r2, i2) {
    __publicField(this, "scopeDepth");
    __publicField(this, "parentScopes");
    __publicField(this, "fontStyle");
    __publicField(this, "foreground");
    __publicField(this, "background");
    this.scopeDepth = e12, this.parentScopes = t2 || ce, this.fontStyle = n2, this.foreground = r2, this.background = i2;
  }
  clone() {
    return new e3(this.scopeDepth, this.parentScopes, this.fontStyle, this.foreground, this.background);
  }
  static cloneArr(e12) {
    let t2 = [];
    for (let n2 = 0, r2 = e12.length; n2 < r2; n2++) t2[n2] = e12[n2].clone();
    return t2;
  }
  acceptOverwrite(e12, t2, n2, r2) {
    this.scopeDepth > e12 ? console.log(`how did this happen?`) : this.scopeDepth = e12, t2 !== -1 && (this.fontStyle = t2), n2 !== 0 && (this.foreground = n2), r2 !== 0 && (this.background = r2);
  }
}, ue = class e4 {
  constructor(e12, t2 = [], n2 = {}) {
    __publicField(this, "_rulesWithParentScopes");
    this._mainRule = e12, this._children = n2, this._rulesWithParentScopes = t2;
  }
  static _cmpBySpecificity(e12, t2) {
    if (e12.scopeDepth !== t2.scopeDepth) return t2.scopeDepth - e12.scopeDepth;
    let n2 = 0, r2 = 0;
    for (; e12.parentScopes[n2] === `>` && n2++, t2.parentScopes[r2] === `>` && r2++, !(n2 >= e12.parentScopes.length || r2 >= t2.parentScopes.length); ) {
      let i2 = t2.parentScopes[r2].length - e12.parentScopes[n2].length;
      if (i2 !== 0) return i2;
      n2++, r2++;
    }
    return t2.parentScopes.length - e12.parentScopes.length;
  }
  match(t2) {
    if (t2 !== ``) {
      let e12 = t2.indexOf(`.`), n3, r2;
      if (e12 === -1 ? (n3 = t2, r2 = ``) : (n3 = t2.substring(0, e12), r2 = t2.substring(e12 + 1)), this._children.hasOwnProperty(n3)) return this._children[n3].match(r2);
    }
    let n2 = this._rulesWithParentScopes.concat(this._mainRule);
    return n2.sort(e4._cmpBySpecificity), n2;
  }
  insert(t2, n2, r2, i2, a2, o2) {
    if (n2 === ``) {
      this._doInsertHere(t2, r2, i2, a2, o2);
      return;
    }
    let s2 = n2.indexOf(`.`), c2, l2;
    s2 === -1 ? (c2 = n2, l2 = ``) : (c2 = n2.substring(0, s2), l2 = n2.substring(s2 + 1));
    let u2;
    this._children.hasOwnProperty(c2) ? u2 = this._children[c2] : (u2 = new e4(this._mainRule.clone(), le.cloneArr(this._rulesWithParentScopes)), this._children[c2] = u2), u2.insert(t2 + 1, l2, r2, i2, a2, o2);
  }
  _doInsertHere(e12, t2, n2, r2, i2) {
    if (t2 === null) {
      this._mainRule.acceptOverwrite(e12, n2, r2, i2);
      return;
    }
    for (let a2 = 0, o2 = this._rulesWithParentScopes.length; a2 < o2; a2++) {
      let o3 = this._rulesWithParentScopes[a2];
      if (h(o3.parentScopes, t2) === 0) {
        o3.acceptOverwrite(e12, n2, r2, i2);
        return;
      }
    }
    n2 === -1 && (n2 = this._mainRule.fontStyle), r2 === 0 && (r2 = this._mainRule.foreground), i2 === 0 && (i2 = this._mainRule.background), this._rulesWithParentScopes.push(new le(e12, t2, n2, r2, i2));
  }
}, x = class e5 {
  static toBinaryStr(e12) {
    return e12.toString(2).padStart(32, `0`);
  }
  static print(t2) {
    let n2 = e5.getLanguageId(t2), r2 = e5.getTokenType(t2), i2 = e5.getFontStyle(t2), a2 = e5.getForeground(t2), o2 = e5.getBackground(t2);
    console.log({ languageId: n2, tokenType: r2, fontStyle: i2, foreground: a2, background: o2 });
  }
  static getLanguageId(e12) {
    return (e12 & 255) >>> 0;
  }
  static getTokenType(e12) {
    return (e12 & 768) >>> 8;
  }
  static containsBalancedBrackets(e12) {
    return (e12 & 1024) != 0;
  }
  static getFontStyle(e12) {
    return (e12 & 30720) >>> 11;
  }
  static getForeground(e12) {
    return (e12 & 16744448) >>> 15;
  }
  static getBackground(e12) {
    return (e12 & 4278190080) >>> 24;
  }
  static set(t2, n2, r2, i2, a2, o2, s2) {
    let c2 = e5.getLanguageId(t2), l2 = e5.getTokenType(t2), u2 = +!!e5.containsBalancedBrackets(t2), d2 = e5.getFontStyle(t2), f2 = e5.getForeground(t2), p2 = e5.getBackground(t2);
    return n2 !== 0 && (c2 = n2), r2 !== 8 && (l2 = fe(r2)), i2 !== null && (u2 = +!!i2), a2 !== -1 && (d2 = a2), o2 !== 0 && (f2 = o2), s2 !== 0 && (p2 = s2), (c2 << 0 | l2 << 8 | u2 << 10 | d2 << 11 | f2 << 15 | p2 << 24) >>> 0;
  }
};
function de(e12) {
  return e12;
}
function fe(e12) {
  return e12;
}
function S(e12, t2) {
  let n2 = [], r2 = me(e12), i2 = r2.next();
  for (; i2 !== null; ) {
    let e13 = 0;
    if (i2.length === 2 && i2.charAt(1) === `:`) {
      switch (i2.charAt(0)) {
        case `R`:
          e13 = 1;
          break;
        case `L`:
          e13 = -1;
          break;
        default:
          console.log(`Unknown priority ${i2} in scope selector`);
      }
      i2 = r2.next();
    }
    let t3 = o2();
    if (n2.push({ matcher: t3, priority: e13 }), i2 !== `,`) break;
    i2 = r2.next();
  }
  return n2;
  function a2() {
    if (i2 === `-`) {
      i2 = r2.next();
      let e13 = a2();
      return (t3) => !!e13 && !e13(t3);
    }
    if (i2 === `(`) {
      i2 = r2.next();
      let e13 = s2();
      return i2 === `)` && (i2 = r2.next()), e13;
    }
    if (pe(i2)) {
      let e13 = [];
      do
        e13.push(i2), i2 = r2.next();
      while (pe(i2));
      return (n3) => t2(e13, n3);
    }
    return null;
  }
  function o2() {
    let e13 = [], t3 = a2();
    for (; t3; ) e13.push(t3), t3 = a2();
    return (t4) => e13.every((e14) => e14(t4));
  }
  function s2() {
    let e13 = [], t3 = o2();
    for (; t3 && (e13.push(t3), i2 === `|` || i2 === `,`); ) {
      do
        i2 = r2.next();
      while (i2 === `|` || i2 === `,`);
      t3 = o2();
    }
    return (t4) => e13.some((e14) => e14(t4));
  }
}
function pe(e12) {
  return !!e12 && !!e12.match(/[\w\.:]+/);
}
function me(e12) {
  let t2 = /([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g, n2 = t2.exec(e12);
  return { next: () => {
    if (!n2) return null;
    let r2 = n2[0];
    return n2 = t2.exec(e12), r2;
  } };
}
function he(e12) {
  typeof e12.dispose == `function` && e12.dispose();
}
var C = class {
  constructor(e12) {
    this.scopeName = e12;
  }
  toKey() {
    return this.scopeName;
  }
}, ge = class {
  constructor(e12, t2) {
    this.scopeName = e12, this.ruleName = t2;
  }
  toKey() {
    return `${this.scopeName}#${this.ruleName}`;
  }
}, _e = class {
  constructor() {
    __publicField(this, "_references", []);
    __publicField(this, "_seenReferenceKeys", /* @__PURE__ */ new Set());
    __publicField(this, "visitedRule", /* @__PURE__ */ new Set());
  }
  get references() {
    return this._references;
  }
  add(e12) {
    let t2 = e12.toKey();
    this._seenReferenceKeys.has(t2) || (this._seenReferenceKeys.add(t2), this._references.push(e12));
  }
}, ve = class {
  constructor(e12, t2) {
    __publicField(this, "seenFullScopeRequests", /* @__PURE__ */ new Set());
    __publicField(this, "seenPartialScopeRequests", /* @__PURE__ */ new Set());
    __publicField(this, "Q");
    this.repo = e12, this.initialScopeName = t2, this.seenFullScopeRequests.add(this.initialScopeName), this.Q = [new C(this.initialScopeName)];
  }
  processQueue() {
    let e12 = this.Q;
    this.Q = [];
    let t2 = new _e();
    for (let n2 of e12) ye(n2, this.initialScopeName, this.repo, t2);
    for (let e13 of t2.references) if (e13 instanceof C) {
      if (this.seenFullScopeRequests.has(e13.scopeName)) continue;
      this.seenFullScopeRequests.add(e13.scopeName), this.Q.push(e13);
    } else {
      if (this.seenFullScopeRequests.has(e13.scopeName) || this.seenPartialScopeRequests.has(e13.toKey())) continue;
      this.seenPartialScopeRequests.add(e13.toKey()), this.Q.push(e13);
    }
  }
};
function ye(e12, t2, n2, r2) {
  let i2 = n2.lookup(e12.scopeName);
  if (!i2) {
    if (e12.scopeName === t2) throw Error(`No grammar provided for <${t2}>`);
    return;
  }
  let a2 = n2.lookup(t2);
  e12 instanceof C ? xe({ baseGrammar: a2, selfGrammar: i2 }, r2) : be(e12.ruleName, { baseGrammar: a2, selfGrammar: i2, repository: i2.repository }, r2);
  let o2 = n2.injections(e12.scopeName);
  if (o2) for (let e13 of o2) r2.add(new C(e13));
}
function be(e12, t2, n2) {
  if (t2.repository && t2.repository[e12]) {
    let r2 = t2.repository[e12];
    Se([r2], t2, n2);
  }
}
function xe(e12, t2) {
  e12.selfGrammar.patterns && Array.isArray(e12.selfGrammar.patterns) && Se(e12.selfGrammar.patterns, { ...e12, repository: e12.selfGrammar.repository }, t2), e12.selfGrammar.injections && Se(Object.values(e12.selfGrammar.injections), { ...e12, repository: e12.selfGrammar.repository }, t2);
}
function Se(e12, t2, n2) {
  for (let r2 of e12) {
    if (n2.visitedRule.has(r2)) continue;
    n2.visitedRule.add(r2);
    let e13 = r2.repository ? u({}, t2.repository, r2.repository) : t2.repository;
    Array.isArray(r2.patterns) && Se(r2.patterns, { ...t2, repository: e13 }, n2);
    let i2 = r2.include;
    if (!i2) continue;
    let a2 = Oe(i2);
    switch (a2.kind) {
      case 0:
        xe({ ...t2, selfGrammar: t2.baseGrammar }, n2);
        break;
      case 1:
        xe(t2, n2);
        break;
      case 2:
        be(a2.ruleName, { ...t2, repository: e13 }, n2);
        break;
      case 3:
      case 4:
        let r3 = a2.scopeName === t2.selfGrammar.scopeName ? t2.selfGrammar : a2.scopeName === t2.baseGrammar.scopeName ? t2.baseGrammar : void 0;
        if (r3) {
          let i3 = { baseGrammar: t2.baseGrammar, selfGrammar: r3, repository: e13 };
          a2.kind === 4 ? be(a2.ruleName, i3, n2) : xe(i3, n2);
        } else a2.kind === 4 ? n2.add(new ge(a2.scopeName, a2.ruleName)) : n2.add(new C(a2.scopeName));
        break;
    }
  }
}
var Ce = class {
  constructor() {
    __publicField(this, "kind", 0);
  }
}, we = class {
  constructor() {
    __publicField(this, "kind", 1);
  }
}, Te = class {
  constructor(e12) {
    __publicField(this, "kind", 2);
    this.ruleName = e12;
  }
}, Ee = class {
  constructor(e12) {
    __publicField(this, "kind", 3);
    this.scopeName = e12;
  }
}, De = class {
  constructor(e12, t2) {
    __publicField(this, "kind", 4);
    this.scopeName = e12, this.ruleName = t2;
  }
};
function Oe(e12) {
  if (e12 === `$base`) return new Ce();
  if (e12 === `$self`) return new we();
  let t2 = e12.indexOf(`#`);
  return t2 === -1 ? new Ee(e12) : t2 === 0 ? new Te(e12.substring(1)) : new De(e12.substring(0, t2), e12.substring(t2 + 1));
}
var ke = /\\(\d+)/, Ae = /\\(\d+)/g, je = -1, Me = -2;
function Ne(e12) {
  return e12;
}
function Pe(e12) {
  return e12;
}
var w = class {
  constructor(e12, t2, n2, r2) {
    __publicField(this, "$location");
    __publicField(this, "id");
    __publicField(this, "_nameIsCapturing");
    __publicField(this, "_name");
    __publicField(this, "_contentNameIsCapturing");
    __publicField(this, "_contentName");
    this.$location = e12, this.id = t2, this._name = n2 || null, this._nameIsCapturing = p.hasCaptures(this._name), this._contentName = r2 || null, this._contentNameIsCapturing = p.hasCaptures(this._contentName);
  }
  get debugName() {
    let e12 = this.$location ? `${d(this.$location.filename)}:${this.$location.line}` : `unknown`;
    return `${this.constructor.name}#${this.id} @ ${e12}`;
  }
  getName(e12, t2) {
    return !this._nameIsCapturing || this._name === null || e12 === null || t2 === null ? this._name : p.replaceCaptures(this._name, e12, t2);
  }
  getContentName(e12, t2) {
    return !this._contentNameIsCapturing || this._contentName === null ? this._contentName : p.replaceCaptures(this._contentName, e12, t2);
  }
}, Fe = class extends w {
  constructor(e12, t2, n2, r2, i2) {
    super(e12, t2, n2, r2);
    __publicField(this, "retokenizeCapturedWithRuleId");
    this.retokenizeCapturedWithRuleId = i2;
  }
  dispose() {
  }
  collectPatterns(e12, t2) {
    throw Error(`Not supported!`);
  }
  compile(e12, t2) {
    throw Error(`Not supported!`);
  }
  compileAG(e12, t2, n2, r2) {
    throw Error(`Not supported!`);
  }
}, Ie = class extends w {
  constructor(e12, t2, n2, r2, i2) {
    super(e12, t2, n2, null);
    __publicField(this, "_match");
    __publicField(this, "captures");
    __publicField(this, "_cachedCompiledPatterns");
    this._match = new E(r2, this.id), this.captures = i2, this._cachedCompiledPatterns = null;
  }
  dispose() {
    this._cachedCompiledPatterns && (this._cachedCompiledPatterns = (this._cachedCompiledPatterns.dispose(), null));
  }
  get debugMatchRegExp() {
    return `${this._match.source}`;
  }
  collectPatterns(e12, t2) {
    t2.push(this._match);
  }
  compile(e12, t2) {
    return this._getCachedCompiledPatterns(e12).compile(e12);
  }
  compileAG(e12, t2, n2, r2) {
    return this._getCachedCompiledPatterns(e12).compileAG(e12, n2, r2);
  }
  _getCachedCompiledPatterns(e12) {
    return this._cachedCompiledPatterns || (this._cachedCompiledPatterns = new D(), this.collectPatterns(e12, this._cachedCompiledPatterns)), this._cachedCompiledPatterns;
  }
}, Le = class extends w {
  constructor(e12, t2, n2, r2, i2) {
    super(e12, t2, n2, r2);
    __publicField(this, "hasMissingPatterns");
    __publicField(this, "patterns");
    __publicField(this, "_cachedCompiledPatterns");
    this.patterns = i2.patterns, this.hasMissingPatterns = i2.hasMissingPatterns, this._cachedCompiledPatterns = null;
  }
  dispose() {
    this._cachedCompiledPatterns && (this._cachedCompiledPatterns = (this._cachedCompiledPatterns.dispose(), null));
  }
  collectPatterns(e12, t2) {
    for (let n2 of this.patterns) e12.getRule(n2).collectPatterns(e12, t2);
  }
  compile(e12, t2) {
    return this._getCachedCompiledPatterns(e12).compile(e12);
  }
  compileAG(e12, t2, n2, r2) {
    return this._getCachedCompiledPatterns(e12).compileAG(e12, n2, r2);
  }
  _getCachedCompiledPatterns(e12) {
    return this._cachedCompiledPatterns || (this._cachedCompiledPatterns = new D(), this.collectPatterns(e12, this._cachedCompiledPatterns)), this._cachedCompiledPatterns;
  }
}, Re = class extends w {
  constructor(e12, t2, n2, r2, i2, a2, o2, s2, c2, l2) {
    super(e12, t2, n2, r2);
    __publicField(this, "_begin");
    __publicField(this, "beginCaptures");
    __publicField(this, "_end");
    __publicField(this, "endHasBackReferences");
    __publicField(this, "endCaptures");
    __publicField(this, "applyEndPatternLast");
    __publicField(this, "hasMissingPatterns");
    __publicField(this, "patterns");
    __publicField(this, "_cachedCompiledPatterns");
    this._begin = new E(i2, this.id), this.beginCaptures = a2, this._end = new E(o2 || `\uFFFF`, -1), this.endHasBackReferences = this._end.hasBackReferences, this.endCaptures = s2, this.applyEndPatternLast = c2 || false, this.patterns = l2.patterns, this.hasMissingPatterns = l2.hasMissingPatterns, this._cachedCompiledPatterns = null;
  }
  dispose() {
    this._cachedCompiledPatterns && (this._cachedCompiledPatterns = (this._cachedCompiledPatterns.dispose(), null));
  }
  get debugBeginRegExp() {
    return `${this._begin.source}`;
  }
  get debugEndRegExp() {
    return `${this._end.source}`;
  }
  getEndWithResolvedBackReferences(e12, t2) {
    return this._end.resolveBackReferences(e12, t2);
  }
  collectPatterns(e12, t2) {
    t2.push(this._begin);
  }
  compile(e12, t2) {
    return this._getCachedCompiledPatterns(e12, t2).compile(e12);
  }
  compileAG(e12, t2, n2, r2) {
    return this._getCachedCompiledPatterns(e12, t2).compileAG(e12, n2, r2);
  }
  _getCachedCompiledPatterns(e12, t2) {
    if (!this._cachedCompiledPatterns) {
      this._cachedCompiledPatterns = new D();
      for (let t3 of this.patterns) e12.getRule(t3).collectPatterns(e12, this._cachedCompiledPatterns);
      this.applyEndPatternLast ? this._cachedCompiledPatterns.push(this._end.hasBackReferences ? this._end.clone() : this._end) : this._cachedCompiledPatterns.unshift(this._end.hasBackReferences ? this._end.clone() : this._end);
    }
    return this._end.hasBackReferences && (this.applyEndPatternLast ? this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length() - 1, t2) : this._cachedCompiledPatterns.setSource(0, t2)), this._cachedCompiledPatterns;
  }
}, T = class extends w {
  constructor(e12, t2, n2, r2, i2, a2, o2, s2, c2) {
    super(e12, t2, n2, r2);
    __publicField(this, "_begin");
    __publicField(this, "beginCaptures");
    __publicField(this, "whileCaptures");
    __publicField(this, "_while");
    __publicField(this, "whileHasBackReferences");
    __publicField(this, "hasMissingPatterns");
    __publicField(this, "patterns");
    __publicField(this, "_cachedCompiledPatterns");
    __publicField(this, "_cachedCompiledWhilePatterns");
    this._begin = new E(i2, this.id), this.beginCaptures = a2, this.whileCaptures = s2, this._while = new E(o2, Me), this.whileHasBackReferences = this._while.hasBackReferences, this.patterns = c2.patterns, this.hasMissingPatterns = c2.hasMissingPatterns, this._cachedCompiledPatterns = null, this._cachedCompiledWhilePatterns = null;
  }
  dispose() {
    this._cachedCompiledPatterns && (this._cachedCompiledPatterns = (this._cachedCompiledPatterns.dispose(), null)), this._cachedCompiledWhilePatterns && (this._cachedCompiledWhilePatterns = (this._cachedCompiledWhilePatterns.dispose(), null));
  }
  get debugBeginRegExp() {
    return `${this._begin.source}`;
  }
  get debugWhileRegExp() {
    return `${this._while.source}`;
  }
  getWhileWithResolvedBackReferences(e12, t2) {
    return this._while.resolveBackReferences(e12, t2);
  }
  collectPatterns(e12, t2) {
    t2.push(this._begin);
  }
  compile(e12, t2) {
    return this._getCachedCompiledPatterns(e12).compile(e12);
  }
  compileAG(e12, t2, n2, r2) {
    return this._getCachedCompiledPatterns(e12).compileAG(e12, n2, r2);
  }
  _getCachedCompiledPatterns(e12) {
    if (!this._cachedCompiledPatterns) {
      this._cachedCompiledPatterns = new D();
      for (let t2 of this.patterns) e12.getRule(t2).collectPatterns(e12, this._cachedCompiledPatterns);
    }
    return this._cachedCompiledPatterns;
  }
  compileWhile(e12, t2) {
    return this._getCachedCompiledWhilePatterns(e12, t2).compile(e12);
  }
  compileWhileAG(e12, t2, n2, r2) {
    return this._getCachedCompiledWhilePatterns(e12, t2).compileAG(e12, n2, r2);
  }
  _getCachedCompiledWhilePatterns(e12, t2) {
    return this._cachedCompiledWhilePatterns || (this._cachedCompiledWhilePatterns = new D(), this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences ? this._while.clone() : this._while)), this._while.hasBackReferences && this._cachedCompiledWhilePatterns.setSource(0, t2 || `\uFFFF`), this._cachedCompiledWhilePatterns;
  }
}, ze = class e6 {
  static createCaptureRule(e12, t2, n2, r2, i2) {
    return e12.registerRule((e13) => new Fe(t2, e13, n2, r2, i2));
  }
  static getCompiledRuleId(t2, n2, r2) {
    return t2.id || n2.registerRule((i2) => {
      if (t2.id = i2, t2.match) return new Ie(t2.$vscodeTextmateLocation, t2.id, t2.name, t2.match, e6._compileCaptures(t2.captures, n2, r2));
      if (t2.begin === void 0) {
        t2.repository && (r2 = u({}, r2, t2.repository));
        let i3 = t2.patterns;
        return i3 === void 0 && t2.include && (i3 = [{ include: t2.include }]), new Le(t2.$vscodeTextmateLocation, t2.id, t2.name, t2.contentName, e6._compilePatterns(i3, n2, r2));
      }
      return t2.while ? new T(t2.$vscodeTextmateLocation, t2.id, t2.name, t2.contentName, t2.begin, e6._compileCaptures(t2.beginCaptures || t2.captures, n2, r2), t2.while, e6._compileCaptures(t2.whileCaptures || t2.captures, n2, r2), e6._compilePatterns(t2.patterns, n2, r2)) : new Re(t2.$vscodeTextmateLocation, t2.id, t2.name, t2.contentName, t2.begin, e6._compileCaptures(t2.beginCaptures || t2.captures, n2, r2), t2.end, e6._compileCaptures(t2.endCaptures || t2.captures, n2, r2), t2.applyEndPatternLast, e6._compilePatterns(t2.patterns, n2, r2));
    }), t2.id;
  }
  static _compileCaptures(t2, n2, r2) {
    let i2 = [];
    if (t2) {
      let a2 = 0;
      for (let e12 in t2) {
        if (e12 === `$vscodeTextmateLocation`) continue;
        let t3 = parseInt(e12, 10);
        t3 > a2 && (a2 = t3);
      }
      for (let e12 = 0; e12 <= a2; e12++) i2[e12] = null;
      for (let a3 in t2) {
        if (a3 === `$vscodeTextmateLocation`) continue;
        let o2 = parseInt(a3, 10), s2 = 0;
        t2[a3].patterns && (s2 = e6.getCompiledRuleId(t2[a3], n2, r2)), i2[o2] = e6.createCaptureRule(n2, t2[a3].$vscodeTextmateLocation, t2[a3].name, t2[a3].contentName, s2);
      }
    }
    return i2;
  }
  static _compilePatterns(t2, n2, r2) {
    let i2 = [];
    if (t2) for (let a2 = 0, o2 = t2.length; a2 < o2; a2++) {
      let o3 = t2[a2], s2 = -1;
      if (o3.include) {
        let t3 = Oe(o3.include);
        switch (t3.kind) {
          case 0:
          case 1:
            s2 = e6.getCompiledRuleId(r2[o3.include], n2, r2);
            break;
          case 2:
            let i3 = r2[t3.ruleName];
            i3 && (s2 = e6.getCompiledRuleId(i3, n2, r2));
            break;
          case 3:
          case 4:
            let a3 = t3.scopeName, c2 = t3.kind === 4 ? t3.ruleName : null, l2 = n2.getExternalGrammar(a3, r2);
            if (l2) if (c2) {
              let t4 = l2.repository[c2];
              t4 && (s2 = e6.getCompiledRuleId(t4, n2, l2.repository));
            } else s2 = e6.getCompiledRuleId(l2.repository.$self, n2, l2.repository);
            break;
        }
      } else s2 = e6.getCompiledRuleId(o3, n2, r2);
      if (s2 !== -1) {
        let e12 = n2.getRule(s2), t3 = false;
        if ((e12 instanceof Le || e12 instanceof Re || e12 instanceof T) && e12.hasMissingPatterns && e12.patterns.length === 0 && (t3 = true), t3) continue;
        i2.push(s2);
      }
    }
    return { patterns: i2, hasMissingPatterns: (t2 ? t2.length : 0) !== i2.length };
  }
}, E = class e7 {
  constructor(e12, t2) {
    __publicField(this, "source");
    __publicField(this, "ruleId");
    __publicField(this, "hasAnchor");
    __publicField(this, "hasBackReferences");
    __publicField(this, "_anchorCache");
    if (e12 && typeof e12 == `string`) {
      let t3 = e12.length, n2 = 0, r2 = [], i2 = false;
      for (let a2 = 0; a2 < t3; a2++) if (e12.charAt(a2) === `\\` && a2 + 1 < t3) {
        let t4 = e12.charAt(a2 + 1);
        t4 === `z` ? (r2.push(e12.substring(n2, a2)), r2.push(`$(?!\\n)(?<!\\n)`), n2 = a2 + 2) : (t4 === `A` || t4 === `G`) && (i2 = true), a2++;
      }
      this.hasAnchor = i2, n2 === 0 ? this.source = e12 : (r2.push(e12.substring(n2, t3)), this.source = r2.join(``));
    } else this.hasAnchor = false, this.source = e12;
    this.hasAnchor ? this._anchorCache = this._buildAnchorCache() : this._anchorCache = null, this.ruleId = t2, typeof this.source == `string` ? this.hasBackReferences = ke.test(this.source) : this.hasBackReferences = false;
  }
  clone() {
    return new e7(this.source, this.ruleId);
  }
  setSource(e12) {
    this.source !== e12 && (this.source = e12, this.hasAnchor && (this._anchorCache = this._buildAnchorCache()));
  }
  resolveBackReferences(e12, t2) {
    if (typeof this.source != `string`) throw Error(`This method should only be called if the source is a string`);
    let n2 = t2.map((t3) => e12.substring(t3.start, t3.end));
    return Ae.lastIndex = 0, this.source.replace(Ae, (e13, t3) => _(n2[parseInt(t3, 10)] || ``));
  }
  _buildAnchorCache() {
    if (typeof this.source != `string`) throw Error(`This method should only be called if the source is a string`);
    let e12 = [], t2 = [], n2 = [], r2 = [], i2, a2, o2, s2;
    for (i2 = 0, a2 = this.source.length; i2 < a2; i2++) o2 = this.source.charAt(i2), e12[i2] = o2, t2[i2] = o2, n2[i2] = o2, r2[i2] = o2, o2 === `\\` && i2 + 1 < a2 && (s2 = this.source.charAt(i2 + 1), s2 === `A` ? (e12[i2 + 1] = `\uFFFF`, t2[i2 + 1] = `\uFFFF`, n2[i2 + 1] = `A`, r2[i2 + 1] = `A`) : s2 === `G` ? (e12[i2 + 1] = `\uFFFF`, t2[i2 + 1] = `G`, n2[i2 + 1] = `\uFFFF`, r2[i2 + 1] = `G`) : (e12[i2 + 1] = s2, t2[i2 + 1] = s2, n2[i2 + 1] = s2, r2[i2 + 1] = s2), i2++);
    return { A0_G0: e12.join(``), A0_G1: t2.join(``), A1_G0: n2.join(``), A1_G1: r2.join(``) };
  }
  resolveAnchors(e12, t2) {
    return !this.hasAnchor || !this._anchorCache || typeof this.source != `string` ? this.source : e12 ? t2 ? this._anchorCache.A1_G1 : this._anchorCache.A1_G0 : t2 ? this._anchorCache.A0_G1 : this._anchorCache.A0_G0;
  }
}, D = class {
  constructor() {
    __publicField(this, "_items");
    __publicField(this, "_hasAnchors");
    __publicField(this, "_cached");
    __publicField(this, "_anchorCache");
    this._items = [], this._hasAnchors = false, this._cached = null, this._anchorCache = { A0_G0: null, A0_G1: null, A1_G0: null, A1_G1: null };
  }
  dispose() {
    this._disposeCaches();
  }
  _disposeCaches() {
    this._cached && (this._cached = (this._cached.dispose(), null)), this._anchorCache.A0_G0 && (this._anchorCache.A0_G0.dispose(), this._anchorCache.A0_G0 = null), this._anchorCache.A0_G1 && (this._anchorCache.A0_G1.dispose(), this._anchorCache.A0_G1 = null), this._anchorCache.A1_G0 && (this._anchorCache.A1_G0.dispose(), this._anchorCache.A1_G0 = null), this._anchorCache.A1_G1 && (this._anchorCache.A1_G1.dispose(), this._anchorCache.A1_G1 = null);
  }
  push(e12) {
    this._items.push(e12), this._hasAnchors = this._hasAnchors || e12.hasAnchor;
  }
  unshift(e12) {
    this._items.unshift(e12), this._hasAnchors = this._hasAnchors || e12.hasAnchor;
  }
  length() {
    return this._items.length;
  }
  setSource(e12, t2) {
    this._items[e12].source !== t2 && (this._disposeCaches(), this._items[e12].setSource(t2));
  }
  compile(e12) {
    if (!this._cached) {
      let t2 = this._items.map((e13) => e13.source);
      this._cached = new Be(e12, t2, this._items.map((e13) => e13.ruleId));
    }
    return this._cached;
  }
  compileAG(e12, t2, n2) {
    return this._hasAnchors ? t2 ? n2 ? (this._anchorCache.A1_G1 || (this._anchorCache.A1_G1 = this._resolveAnchors(e12, t2, n2)), this._anchorCache.A1_G1) : (this._anchorCache.A1_G0 || (this._anchorCache.A1_G0 = this._resolveAnchors(e12, t2, n2)), this._anchorCache.A1_G0) : n2 ? (this._anchorCache.A0_G1 || (this._anchorCache.A0_G1 = this._resolveAnchors(e12, t2, n2)), this._anchorCache.A0_G1) : (this._anchorCache.A0_G0 || (this._anchorCache.A0_G0 = this._resolveAnchors(e12, t2, n2)), this._anchorCache.A0_G0) : this.compile(e12);
  }
  _resolveAnchors(e12, t2, n2) {
    return new Be(e12, this._items.map((e13) => e13.resolveAnchors(t2, n2)), this._items.map((e13) => e13.ruleId));
  }
}, Be = class {
  constructor(e12, t2, n2) {
    __publicField(this, "scanner");
    this.regExps = t2, this.rules = n2, this.scanner = e12.createOnigScanner(t2);
  }
  dispose() {
    typeof this.scanner.dispose == `function` && this.scanner.dispose();
  }
  toString() {
    let e12 = [];
    for (let t2 = 0, n2 = this.rules.length; t2 < n2; t2++) e12.push(`   - ` + this.rules[t2] + `: ` + this.regExps[t2]);
    return e12.join(`
`);
  }
  findNextMatchSync(e12, t2, n2) {
    let r2 = this.scanner.findNextMatchSync(e12, t2, n2);
    return r2 ? { ruleId: this.rules[r2.index], captureIndices: r2.captureIndices } : null;
  }
}, Ve = class {
  constructor(e12, t2) {
    this.languageId = e12, this.tokenType = t2;
  }
}, He = (_a = class {
  constructor(e12, t2) {
    __publicField(this, "_defaultAttributes");
    __publicField(this, "_embeddedLanguagesMatcher");
    __publicField(this, "_getBasicScopeAttributes", new v((e12) => new Ve(this._scopeToLanguage(e12), this._toStandardTokenType(e12))));
    this._defaultAttributes = new Ve(e12, 8), this._embeddedLanguagesMatcher = new Ue(Object.entries(t2 || {}));
  }
  getDefaultAttributes() {
    return this._defaultAttributes;
  }
  getBasicScopeAttributes(t2) {
    return t2 === null ? _a._NULL_SCOPE_METADATA : this._getBasicScopeAttributes.get(t2);
  }
  _scopeToLanguage(e12) {
    return this._embeddedLanguagesMatcher.match(e12) || 0;
  }
  _toStandardTokenType(t2) {
    let n2 = t2.match(_a.STANDARD_TOKEN_TYPE_REGEXP);
    if (!n2) return 8;
    switch (n2[1]) {
      case `comment`:
        return 1;
      case `string`:
        return 2;
      case `regex`:
        return 3;
      case `meta.embedded`:
        return 0;
    }
    throw Error(`Unexpected match for standard token type!`);
  }
}, __publicField(_a, "_NULL_SCOPE_METADATA", new Ve(0, 0)), __publicField(_a, "STANDARD_TOKEN_TYPE_REGEXP", /\b(comment|string|regex|meta\.embedded)\b/), _a), Ue = class {
  constructor(e12) {
    __publicField(this, "values");
    __publicField(this, "scopesRegExp");
    if (e12.length === 0) this.values = null, this.scopesRegExp = null;
    else {
      this.values = new Map(e12);
      let t2 = e12.map(([e13, t3]) => _(e13));
      t2.sort(), t2.reverse(), this.scopesRegExp = RegExp(`^((${t2.join(`)|(`)}))($|\\.)`, ``);
    }
  }
  match(e12) {
    if (!this.scopesRegExp) return;
    let t2 = e12.match(this.scopesRegExp);
    if (t2) return this.values.get(t2[1]);
  }
};
r !== void 0 && {}.VSCODE_TEXTMATE_DEBUG;
var We = false, Ge = class {
  constructor(e12, t2) {
    this.stack = e12, this.stoppedEarly = t2;
  }
};
function Ke(e12, t2, n2, r2, i2, a2, o2, s2) {
  let c2 = t2.content.length, l2 = false, u2 = -1;
  if (o2) {
    let o3 = qe(e12, t2, n2, r2, i2, a2);
    i2 = o3.stack, r2 = o3.linePos, n2 = o3.isFirstLine, u2 = o3.anchorPosition;
  }
  let d2 = Date.now();
  for (; !l2; ) {
    if (s2 !== 0 && Date.now() - d2 > s2) return new Ge(i2, true);
    f2();
  }
  return new Ge(i2, false);
  function f2() {
    let o3 = Je(e12, t2, n2, r2, i2, u2);
    if (!o3) {
      a2.produce(i2, c2), l2 = true;
      return;
    }
    let s3 = o3.captureIndices, d3 = o3.matchedRuleId, f3 = s3 && s3.length > 0 ? s3[0].end > r2 : false;
    if (d3 === je) {
      let o4 = i2.getRule(e12);
      a2.produce(i2, s3[0].start), i2 = i2.withContentNameScopesList(i2.nameScopesList), O(e12, t2, n2, i2, a2, o4.endCaptures, s3), a2.produce(i2, s3[0].end);
      let d4 = i2;
      if (i2 = i2.parent, u2 = d4.getAnchorPos(), !f3 && d4.getEnterPos() === r2) {
        i2 = d4, a2.produce(i2, c2), l2 = true;
        return;
      }
    } else {
      let o4 = e12.getRule(d3);
      a2.produce(i2, s3[0].start);
      let p2 = i2, m2 = o4.getName(t2.content, s3), h2 = i2.contentNameScopesList.pushAttributed(m2, e12);
      if (i2 = i2.push(d3, r2, u2, s3[0].end === c2, null, h2, h2), o4 instanceof Re) {
        let r3 = o4;
        O(e12, t2, n2, i2, a2, r3.beginCaptures, s3), a2.produce(i2, s3[0].end), u2 = s3[0].end;
        let d4 = r3.getContentName(t2.content, s3), m3 = h2.pushAttributed(d4, e12);
        if (i2 = i2.withContentNameScopesList(m3), r3.endHasBackReferences && (i2 = i2.withEndRule(r3.getEndWithResolvedBackReferences(t2.content, s3))), !f3 && p2.hasSameRuleAs(i2)) {
          i2 = i2.pop(), a2.produce(i2, c2), l2 = true;
          return;
        }
      } else if (o4 instanceof T) {
        let r3 = o4;
        O(e12, t2, n2, i2, a2, r3.beginCaptures, s3), a2.produce(i2, s3[0].end), u2 = s3[0].end;
        let d4 = r3.getContentName(t2.content, s3), m3 = h2.pushAttributed(d4, e12);
        if (i2 = i2.withContentNameScopesList(m3), r3.whileHasBackReferences && (i2 = i2.withEndRule(r3.getWhileWithResolvedBackReferences(t2.content, s3))), !f3 && p2.hasSameRuleAs(i2)) {
          i2 = i2.pop(), a2.produce(i2, c2), l2 = true;
          return;
        }
      } else if (O(e12, t2, n2, i2, a2, o4.captures, s3), a2.produce(i2, s3[0].end), i2 = i2.pop(), !f3) {
        i2 = i2.safePop(), a2.produce(i2, c2), l2 = true;
        return;
      }
    }
    s3[0].end > r2 && (r2 = s3[0].end, n2 = false);
  }
}
function qe(e12, t2, n2, r2, i2, a2) {
  let o2 = i2.beginRuleCapturedEOL ? 0 : -1, s2 = [];
  for (let t3 = i2; t3; t3 = t3.pop()) {
    let n3 = t3.getRule(e12);
    n3 instanceof T && s2.push({ rule: n3, stack: t3 });
  }
  for (let c2 = s2.pop(); c2; c2 = s2.pop()) {
    let { ruleScanner: s3, findOptions: l2 } = Qe(c2.rule, e12, c2.stack.endRule, n2, r2 === o2), u2 = s3.findNextMatchSync(t2, r2, l2);
    if (u2) {
      if (u2.ruleId !== Me) {
        i2 = c2.stack.pop();
        break;
      }
      u2.captureIndices && u2.captureIndices.length && (a2.produce(c2.stack, u2.captureIndices[0].start), O(e12, t2, n2, c2.stack, a2, c2.rule.whileCaptures, u2.captureIndices), a2.produce(c2.stack, u2.captureIndices[0].end), o2 = u2.captureIndices[0].end, u2.captureIndices[0].end > r2 && (r2 = u2.captureIndices[0].end, n2 = false));
    } else {
      i2 = c2.stack.pop();
      break;
    }
  }
  return { stack: i2, linePos: r2, anchorPosition: o2, isFirstLine: n2 };
}
function Je(e12, t2, n2, r2, i2, a2) {
  let o2 = Ye(e12, t2, n2, r2, i2, a2), s2 = e12.getInjections();
  if (s2.length === 0) return o2;
  let c2 = Xe(s2, e12, t2, n2, r2, i2, a2);
  if (!c2) return o2;
  if (!o2) return c2;
  let l2 = o2.captureIndices[0].start, u2 = c2.captureIndices[0].start;
  return u2 < l2 || c2.priorityMatch && u2 === l2 ? c2 : o2;
}
function Ye(e12, t2, n2, r2, i2, a2) {
  let { ruleScanner: o2, findOptions: s2 } = Ze(i2.getRule(e12), e12, i2.endRule, n2, r2 === a2), c2 = o2.findNextMatchSync(t2, r2, s2);
  return c2 ? { captureIndices: c2.captureIndices, matchedRuleId: c2.ruleId } : null;
}
function Xe(e12, t2, n2, r2, i2, a2, o2) {
  let s2 = Number.MAX_VALUE, c2 = null, l2, u2 = 0, d2 = a2.contentNameScopesList.getScopeNames();
  for (let a3 = 0, f2 = e12.length; a3 < f2; a3++) {
    let f3 = e12[a3];
    if (!f3.matcher(d2)) continue;
    let { ruleScanner: p2, findOptions: m2 } = Ze(t2.getRule(f3.ruleId), t2, null, r2, i2 === o2), h2 = p2.findNextMatchSync(n2, i2, m2);
    if (!h2) continue;
    let g2 = h2.captureIndices[0].start;
    if (!(g2 >= s2) && (s2 = g2, c2 = h2.captureIndices, l2 = h2.ruleId, u2 = f3.priority, s2 === i2)) break;
  }
  return c2 ? { priorityMatch: u2 === -1, captureIndices: c2, matchedRuleId: l2 } : null;
}
function Ze(e12, t2, n2, r2, i2) {
  return We ? { ruleScanner: e12.compile(t2, n2), findOptions: $e(r2, i2) } : { ruleScanner: e12.compileAG(t2, n2, r2, i2), findOptions: 0 };
}
function Qe(e12, t2, n2, r2, i2) {
  return We ? { ruleScanner: e12.compileWhile(t2, n2), findOptions: $e(r2, i2) } : { ruleScanner: e12.compileWhileAG(t2, n2, r2, i2), findOptions: 0 };
}
function $e(e12, t2) {
  let n2 = 0;
  return e12 || (n2 |= 1), t2 || (n2 |= 4), n2;
}
function O(e12, t2, n2, r2, i2, a2, o2) {
  if (a2.length === 0) return;
  let s2 = t2.content, c2 = Math.min(a2.length, o2.length), l2 = [], u2 = o2[0].end;
  for (let t3 = 0; t3 < c2; t3++) {
    let c3 = a2[t3];
    if (c3 === null) continue;
    let d2 = o2[t3];
    if (d2.length === 0) continue;
    if (d2.start > u2) break;
    for (; l2.length > 0 && l2[l2.length - 1].endPos <= d2.start; ) i2.produceFromScopes(l2[l2.length - 1].scopes, l2[l2.length - 1].endPos), l2.pop();
    if (l2.length > 0 ? i2.produceFromScopes(l2[l2.length - 1].scopes, d2.start) : i2.produce(r2, d2.start), c3.retokenizeCapturedWithRuleId) {
      let t4 = c3.getName(s2, o2), a3 = r2.contentNameScopesList.pushAttributed(t4, e12), l3 = c3.getContentName(s2, o2), u3 = a3.pushAttributed(l3, e12), f3 = r2.push(c3.retokenizeCapturedWithRuleId, d2.start, -1, false, null, a3, u3), p2 = e12.createOnigString(s2.substring(0, d2.end));
      Ke(e12, p2, n2 && d2.start === 0, d2.start, f3, i2, false, 0), he(p2);
      continue;
    }
    let f2 = c3.getName(s2, o2);
    if (f2 !== null) {
      let t4 = (l2.length > 0 ? l2[l2.length - 1].scopes : r2.contentNameScopesList).pushAttributed(f2, e12);
      l2.push(new et(t4, d2.end));
    }
  }
  for (; l2.length > 0; ) i2.produceFromScopes(l2[l2.length - 1].scopes, l2[l2.length - 1].endPos), l2.pop();
}
var et = class {
  constructor(e12, t2) {
    __publicField(this, "scopes");
    __publicField(this, "endPos");
    this.scopes = e12, this.endPos = t2;
  }
};
function tt(e12, t2, n2, r2, i2, a2, o2, s2) {
  return new it(e12, t2, n2, r2, i2, a2, o2, s2);
}
function nt(e12, t2, n2, r2, i2) {
  let a2 = S(t2, k), o2 = ze.getCompiledRuleId(n2, r2, i2.repository);
  for (let n3 of a2) e12.push({ debugSelector: t2, matcher: n3.matcher, ruleId: o2, grammar: i2, priority: n3.priority });
}
function k(e12, t2) {
  if (t2.length < e12.length) return false;
  let n2 = 0;
  return e12.every((e13) => {
    for (let r2 = n2; r2 < t2.length; r2++) if (rt(t2[r2], e13)) return n2 = r2 + 1, true;
    return false;
  });
}
function rt(e12, t2) {
  if (!e12) return false;
  if (e12 === t2) return true;
  let n2 = t2.length;
  return e12.length > n2 && e12.substr(0, n2) === t2 && e12[n2] === `.`;
}
var it = class {
  constructor(e12, t2, n2, r2, i2, a2, o2, s2) {
    __publicField(this, "_rootId");
    __publicField(this, "_lastRuleId");
    __publicField(this, "_ruleId2desc");
    __publicField(this, "_includedGrammars");
    __publicField(this, "_grammarRepository");
    __publicField(this, "_grammar");
    __publicField(this, "_injections");
    __publicField(this, "_basicScopeAttributesProvider");
    __publicField(this, "_tokenTypeMatchers");
    if (this._rootScopeName = e12, this.balancedBracketSelectors = a2, this._onigLib = s2, this._basicScopeAttributesProvider = new He(n2, r2), this._rootId = -1, this._lastRuleId = 0, this._ruleId2desc = [null], this._includedGrammars = {}, this._grammarRepository = o2, this._grammar = at(t2, null), this._injections = null, this._tokenTypeMatchers = [], i2) for (let e13 of Object.keys(i2)) {
      let t3 = S(e13, k);
      for (let n3 of t3) this._tokenTypeMatchers.push({ matcher: n3.matcher, type: i2[e13] });
    }
  }
  get themeProvider() {
    return this._grammarRepository;
  }
  dispose() {
    for (let e12 of this._ruleId2desc) e12 && e12.dispose();
  }
  createOnigScanner(e12) {
    return this._onigLib.createOnigScanner(e12);
  }
  createOnigString(e12) {
    return this._onigLib.createOnigString(e12);
  }
  getMetadataForScope(e12) {
    return this._basicScopeAttributesProvider.getBasicScopeAttributes(e12);
  }
  _collectInjections() {
    let e12 = { lookup: (e13) => e13 === this._rootScopeName ? this._grammar : this.getExternalGrammar(e13), injections: (e13) => this._grammarRepository.injections(e13) }, t2 = [], n2 = this._rootScopeName, r2 = e12.lookup(n2);
    if (r2) {
      let e13 = r2.injections;
      if (e13) for (let n3 in e13) nt(t2, n3, e13[n3], this, r2);
      let i2 = this._grammarRepository.injections(n2);
      i2 && i2.forEach((e14) => {
        let n3 = this.getExternalGrammar(e14);
        if (n3) {
          let e15 = n3.injectionSelector;
          e15 && nt(t2, e15, n3, this, n3);
        }
      });
    }
    return t2.sort((e13, t3) => e13.priority - t3.priority), t2;
  }
  getInjections() {
    return this._injections === null && (this._injections = this._collectInjections()), this._injections;
  }
  registerRule(e12) {
    let t2 = ++this._lastRuleId, n2 = e12(Ne(t2));
    return this._ruleId2desc[t2] = n2, n2;
  }
  getRule(e12) {
    return this._ruleId2desc[Pe(e12)];
  }
  getExternalGrammar(e12, t2) {
    if (this._includedGrammars[e12]) return this._includedGrammars[e12];
    if (this._grammarRepository) {
      let n2 = this._grammarRepository.lookup(e12);
      if (n2) return this._includedGrammars[e12] = at(n2, t2 && t2.$base), this._includedGrammars[e12];
    }
  }
  tokenizeLine(e12, t2, n2 = 0) {
    let r2 = this._tokenize(e12, t2, false, n2);
    return { tokens: r2.lineTokens.getResult(r2.ruleStack, r2.lineLength), ruleStack: r2.ruleStack, stoppedEarly: r2.stoppedEarly };
  }
  tokenizeLine2(e12, t2, n2 = 0) {
    let r2 = this._tokenize(e12, t2, true, n2);
    return { tokens: r2.lineTokens.getBinaryResult(r2.ruleStack, r2.lineLength), ruleStack: r2.ruleStack, stoppedEarly: r2.stoppedEarly };
  }
  _tokenize(e12, t2, n2, r2) {
    this._rootId === -1 && (this._rootId = ze.getCompiledRuleId(this._grammar.repository.$self, this, this._grammar.repository), this.getInjections());
    let i2;
    if (!t2 || t2 === ot.NULL) {
      i2 = true;
      let e13 = this._basicScopeAttributesProvider.getDefaultAttributes(), n3 = this.themeProvider.getDefaults(), r3 = x.set(0, e13.languageId, e13.tokenType, null, n3.fontStyle, n3.foregroundId, n3.backgroundId), a3 = this.getRule(this._rootId).getName(null, null), o3;
      o3 = a3 ? A.createRootAndLookUpScopeName(a3, r3, this) : A.createRoot(`unknown`, r3), t2 = new ot(null, this._rootId, -1, -1, false, null, o3, o3);
    } else i2 = false, t2.reset();
    e12 += `
`;
    let a2 = this.createOnigString(e12), o2 = a2.content.length, s2 = new ct(n2, e12, this._tokenTypeMatchers, this.balancedBracketSelectors), c2 = Ke(this, a2, i2, 0, t2, s2, true, r2);
    return he(a2), { lineLength: o2, lineTokens: s2, ruleStack: c2.stack, stoppedEarly: c2.stoppedEarly };
  }
};
function at(e12, t2) {
  return e12 = o(e12), e12.repository = e12.repository || {}, e12.repository.$self = { $vscodeTextmateLocation: e12.$vscodeTextmateLocation, patterns: e12.patterns, name: e12.scopeName }, e12.repository.$base = t2 || e12.repository.$self, e12;
}
var A = class e8 {
  constructor(e12, t2, n2) {
    this.parent = e12, this.scopePath = t2, this.tokenAttributes = n2;
  }
  static fromExtension(t2, n2) {
    let r2 = t2, i2 = t2?.scopePath ?? null;
    for (let t3 of n2) i2 = ee.push(i2, t3.scopeNames), r2 = new e8(r2, i2, t3.encodedTokenAttributes);
    return r2;
  }
  static createRoot(t2, n2) {
    return new e8(null, new ee(null, t2), n2);
  }
  static createRootAndLookUpScopeName(t2, n2, r2) {
    let i2 = r2.getMetadataForScope(t2), a2 = new ee(null, t2), o2 = r2.themeProvider.themeMatch(a2);
    return new e8(null, a2, e8.mergeAttributes(n2, i2, o2));
  }
  get scopeName() {
    return this.scopePath.scopeName;
  }
  toString() {
    return this.getScopeNames().join(` `);
  }
  equals(t2) {
    return e8.equals(this, t2);
  }
  static equals(e12, t2) {
    do {
      if (e12 === t2 || !e12 && !t2) return true;
      if (!e12 || !t2 || e12.scopeName !== t2.scopeName || e12.tokenAttributes !== t2.tokenAttributes) return false;
      e12 = e12.parent, t2 = t2.parent;
    } while (true);
  }
  static mergeAttributes(e12, t2, n2) {
    let r2 = -1, i2 = 0, a2 = 0;
    return n2 !== null && (r2 = n2.fontStyle, i2 = n2.foregroundId, a2 = n2.backgroundId), x.set(e12, t2.languageId, t2.tokenType, null, r2, i2, a2);
  }
  pushAttributed(t2, n2) {
    if (t2 === null) return this;
    if (t2.indexOf(` `) === -1) return e8._pushAttributed(this, t2, n2);
    let r2 = t2.split(/ /g), i2 = this;
    for (let t3 of r2) i2 = e8._pushAttributed(i2, t3, n2);
    return i2;
  }
  static _pushAttributed(t2, n2, r2) {
    let i2 = r2.getMetadataForScope(n2), a2 = t2.scopePath.push(n2), o2 = r2.themeProvider.themeMatch(a2);
    return new e8(t2, a2, e8.mergeAttributes(t2.tokenAttributes, i2, o2));
  }
  getScopeNames() {
    return this.scopePath.getSegments();
  }
  getExtensionIfDefined(e12) {
    let t2 = [], n2 = this;
    for (; n2 && n2 !== e12; ) t2.push({ encodedTokenAttributes: n2.tokenAttributes, scopeNames: n2.scopePath.getExtensionIfDefined(n2.parent?.scopePath ?? null) }), n2 = n2.parent;
    return n2 === e12 ? t2.reverse() : void 0;
  }
}, ot = (_b = class {
  constructor(e12, t2, n2, r2, i2, a2, o2, s2) {
    __publicField(this, "_stackElementBrand");
    __publicField(this, "_enterPos");
    __publicField(this, "_anchorPos");
    __publicField(this, "depth");
    this.parent = e12, this.ruleId = t2, this.beginRuleCapturedEOL = i2, this.endRule = a2, this.nameScopesList = o2, this.contentNameScopesList = s2, this.depth = this.parent ? this.parent.depth + 1 : 1, this._enterPos = n2, this._anchorPos = r2;
  }
  equals(t2) {
    return t2 === null ? false : _b._equals(this, t2);
  }
  static _equals(e12, t2) {
    return e12 === t2 ? true : this._structuralEquals(e12, t2) ? A.equals(e12.contentNameScopesList, t2.contentNameScopesList) : false;
  }
  static _structuralEquals(e12, t2) {
    do {
      if (e12 === t2 || !e12 && !t2) return true;
      if (!e12 || !t2 || e12.depth !== t2.depth || e12.ruleId !== t2.ruleId || e12.endRule !== t2.endRule) return false;
      e12 = e12.parent, t2 = t2.parent;
    } while (true);
  }
  clone() {
    return this;
  }
  static _reset(e12) {
    for (; e12; ) e12._enterPos = -1, e12._anchorPos = -1, e12 = e12.parent;
  }
  reset() {
    _b._reset(this);
  }
  pop() {
    return this.parent;
  }
  safePop() {
    return this.parent ? this.parent : this;
  }
  push(t2, n2, r2, i2, a2, o2, s2) {
    return new _b(this, t2, n2, r2, i2, a2, o2, s2);
  }
  getEnterPos() {
    return this._enterPos;
  }
  getAnchorPos() {
    return this._anchorPos;
  }
  getRule(e12) {
    return e12.getRule(this.ruleId);
  }
  toString() {
    let e12 = [];
    return this._writeString(e12, 0), `[` + e12.join(`,`) + `]`;
  }
  _writeString(e12, t2) {
    return this.parent && (t2 = this.parent._writeString(e12, t2)), e12[t2++] = `(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`, t2;
  }
  withContentNameScopesList(e12) {
    return this.contentNameScopesList === e12 ? this : this.parent.push(this.ruleId, this._enterPos, this._anchorPos, this.beginRuleCapturedEOL, this.endRule, this.nameScopesList, e12);
  }
  withEndRule(t2) {
    return this.endRule === t2 ? this : new _b(this.parent, this.ruleId, this._enterPos, this._anchorPos, this.beginRuleCapturedEOL, t2, this.nameScopesList, this.contentNameScopesList);
  }
  hasSameRuleAs(e12) {
    let t2 = this;
    for (; t2 && t2._enterPos === e12._enterPos; ) {
      if (t2.ruleId === e12.ruleId) return true;
      t2 = t2.parent;
    }
    return false;
  }
  toStateStackFrame() {
    return { ruleId: Pe(this.ruleId), beginRuleCapturedEOL: this.beginRuleCapturedEOL, endRule: this.endRule, nameScopesList: this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList ?? null) ?? [], contentNameScopesList: this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList) ?? [] };
  }
  static pushFrame(t2, n2) {
    let r2 = A.fromExtension(t2?.nameScopesList ?? null, n2.nameScopesList);
    return new _b(t2, Ne(n2.ruleId), n2.enterPos ?? -1, n2.anchorPos ?? -1, n2.beginRuleCapturedEOL, n2.endRule, r2, A.fromExtension(r2, n2.contentNameScopesList));
  }
}, __publicField(_b, "NULL", new _b(null, 0, 0, 0, false, null, null, null)), _b), st = class {
  constructor(e12, t2) {
    __publicField(this, "balancedBracketScopes");
    __publicField(this, "unbalancedBracketScopes");
    __publicField(this, "allowAny", false);
    this.balancedBracketScopes = e12.flatMap((e13) => e13 === `*` ? (this.allowAny = true, []) : S(e13, k).map((e14) => e14.matcher)), this.unbalancedBracketScopes = t2.flatMap((e13) => S(e13, k).map((e14) => e14.matcher));
  }
  get matchesAlways() {
    return this.allowAny && this.unbalancedBracketScopes.length === 0;
  }
  get matchesNever() {
    return this.balancedBracketScopes.length === 0 && !this.allowAny;
  }
  match(e12) {
    for (let t2 of this.unbalancedBracketScopes) if (t2(e12)) return false;
    for (let t2 of this.balancedBracketScopes) if (t2(e12)) return true;
    return this.allowAny;
  }
}, ct = class {
  constructor(e12, t2, n2, r2) {
    __publicField(this, "_emitBinaryTokens");
    __publicField(this, "_lineText");
    __publicField(this, "_tokens");
    __publicField(this, "_binaryTokens");
    __publicField(this, "_lastTokenEndIndex");
    __publicField(this, "_tokenTypeOverrides");
    this.balancedBracketSelectors = r2, this._emitBinaryTokens = e12, this._tokenTypeOverrides = n2, this._lineText = null, this._tokens = [], this._binaryTokens = [], this._lastTokenEndIndex = 0;
  }
  produce(e12, t2) {
    this.produceFromScopes(e12.contentNameScopesList, t2);
  }
  produceFromScopes(e12, t2) {
    if (this._lastTokenEndIndex >= t2) return;
    if (this._emitBinaryTokens) {
      let n3 = e12?.tokenAttributes ?? 0, r2 = false;
      if (this.balancedBracketSelectors?.matchesAlways && (r2 = true), this._tokenTypeOverrides.length > 0 || this.balancedBracketSelectors && !this.balancedBracketSelectors.matchesAlways && !this.balancedBracketSelectors.matchesNever) {
        let t3 = e12?.getScopeNames() ?? [];
        for (let e13 of this._tokenTypeOverrides) e13.matcher(t3) && (n3 = x.set(n3, 0, de(e13.type), null, -1, 0, 0));
        this.balancedBracketSelectors && (r2 = this.balancedBracketSelectors.match(t3));
      }
      if (r2 && (n3 = x.set(n3, 0, 8, r2, -1, 0, 0)), this._binaryTokens.length > 0 && this._binaryTokens[this._binaryTokens.length - 1] === n3) {
        this._lastTokenEndIndex = t2;
        return;
      }
      this._binaryTokens.push(this._lastTokenEndIndex), this._binaryTokens.push(n3), this._lastTokenEndIndex = t2;
      return;
    }
    let n2 = e12?.getScopeNames() ?? [];
    this._tokens.push({ startIndex: this._lastTokenEndIndex, endIndex: t2, scopes: n2 }), this._lastTokenEndIndex = t2;
  }
  getResult(e12, t2) {
    return this._tokens.length > 0 && this._tokens[this._tokens.length - 1].startIndex === t2 - 1 && this._tokens.pop(), this._tokens.length === 0 && (this._lastTokenEndIndex = -1, this.produce(e12, t2), this._tokens[this._tokens.length - 1].startIndex = 0), this._tokens;
  }
  getBinaryResult(e12, t2) {
    this._binaryTokens.length > 0 && this._binaryTokens[this._binaryTokens.length - 2] === t2 - 1 && (this._binaryTokens.pop(), this._binaryTokens.pop()), this._binaryTokens.length === 0 && (this._lastTokenEndIndex = -1, this.produce(e12, t2), this._binaryTokens[this._binaryTokens.length - 2] = 0);
    let n2 = new Uint32Array(this._binaryTokens.length);
    for (let e13 = 0, t3 = this._binaryTokens.length; e13 < t3; e13++) n2[e13] = this._binaryTokens[e13];
    return n2;
  }
}, lt = class {
  constructor(e12, t2) {
    __publicField(this, "_grammars", /* @__PURE__ */ new Map());
    __publicField(this, "_rawGrammars", /* @__PURE__ */ new Map());
    __publicField(this, "_injectionGrammars", /* @__PURE__ */ new Map());
    __publicField(this, "_theme");
    this._onigLib = t2, this._theme = e12;
  }
  dispose() {
    for (let e12 of this._grammars.values()) e12.dispose();
  }
  setTheme(e12) {
    this._theme = e12;
  }
  getColorMap() {
    return this._theme.getColorMap();
  }
  addGrammar(e12, t2) {
    this._rawGrammars.set(e12.scopeName, e12), t2 && this._injectionGrammars.set(e12.scopeName, t2);
  }
  lookup(e12) {
    return this._rawGrammars.get(e12);
  }
  injections(e12) {
    return this._injectionGrammars.get(e12);
  }
  getDefaults() {
    return this._theme.getDefaults();
  }
  themeMatch(e12) {
    return this._theme.match(e12);
  }
  grammarForScopeName(e12, t2, n2, r2, i2) {
    if (!this._grammars.has(e12)) {
      let a2 = this._rawGrammars.get(e12);
      if (!a2) return null;
      this._grammars.set(e12, tt(e12, a2, t2, n2, r2, i2, this, this._onigLib));
    }
    return this._grammars.get(e12);
  }
}, ut = class {
  constructor(e12) {
    __publicField(this, "_options");
    __publicField(this, "_syncRegistry");
    __publicField(this, "_ensureGrammarCache");
    this._options = e12, this._syncRegistry = new lt(y.createFromRawTheme(e12.theme, e12.colorMap), e12.onigLib), this._ensureGrammarCache = /* @__PURE__ */ new Map();
  }
  dispose() {
    this._syncRegistry.dispose();
  }
  setTheme(e12, t2) {
    this._syncRegistry.setTheme(y.createFromRawTheme(e12, t2));
  }
  getColorMap() {
    return this._syncRegistry.getColorMap();
  }
  loadGrammarWithEmbeddedLanguages(e12, t2, n2) {
    return this.loadGrammarWithConfiguration(e12, t2, { embeddedLanguages: n2 });
  }
  loadGrammarWithConfiguration(e12, t2, n2) {
    return this._loadGrammar(e12, t2, n2.embeddedLanguages, n2.tokenTypes, new st(n2.balancedBracketSelectors || [], n2.unbalancedBracketSelectors || []));
  }
  loadGrammar(e12) {
    return this._loadGrammar(e12, 0, null, null, null);
  }
  _loadGrammar(e12, t2, n2, r2, i2) {
    let a2 = new ve(this._syncRegistry, e12);
    for (; a2.Q.length > 0; ) a2.Q.map((e13) => this._loadSingleGrammar(e13.scopeName)), a2.processQueue();
    return this._grammarForScopeName(e12, t2, n2, r2, i2);
  }
  _loadSingleGrammar(e12) {
    this._ensureGrammarCache.has(e12) || (this._doLoadSingleGrammar(e12), this._ensureGrammarCache.set(e12, true));
  }
  _doLoadSingleGrammar(e12) {
    let t2 = this._options.loadGrammar(e12);
    if (t2) {
      let n2 = typeof this._options.getInjections == `function` ? this._options.getInjections(e12) : void 0;
      this._syncRegistry.addGrammar(t2, n2);
    }
  }
  addGrammar(e12, t2 = [], n2 = 0, r2 = null) {
    return this._syncRegistry.addGrammar(e12, t2), this._grammarForScopeName(e12.scopeName, n2, r2);
  }
  _grammarForScopeName(e12, t2 = 0, n2 = null, r2 = null, i2 = null) {
    return this._syncRegistry.grammarForScopeName(e12, t2, n2, r2, i2);
  }
}, dt = ot.NULL;
function j(e12, t2) {
  let n2 = typeof e12 == `string` ? {} : { ...e12.colorReplacements }, r2 = typeof e12 == `string` ? e12 : e12.name;
  for (let [e13, i2] of Object.entries(t2?.colorReplacements || {})) typeof i2 == `string` ? n2[e13] = i2 : e13 === r2 && Object.assign(n2, i2);
  return n2;
}
function M(e12, t2) {
  return e12 && (t2?.[e12?.toLowerCase()] || e12);
}
function ft(e12) {
  return Array.isArray(e12) ? e12 : [e12];
}
async function pt(e12) {
  return Promise.resolve(typeof e12 == `function` ? e12() : e12).then((e13) => e13.default || e13);
}
function mt(e12) {
  return !e12 || [`plaintext`, `txt`, `text`, `plain`].includes(e12);
}
function ht(e12) {
  return e12 === `ansi` || mt(e12);
}
function gt(e12) {
  return e12 === `none`;
}
function _t(e12) {
  return gt(e12);
}
var vt = /(\r?\n)/g;
function yt(e12, t2 = false) {
  if (e12.length === 0) return [[``, 0]];
  let n2 = e12.split(vt), r2 = 0, i2 = [];
  for (let e13 = 0; e13 < n2.length; e13 += 2) {
    let a2 = t2 ? n2[e13] + (n2[e13 + 1] || ``) : n2[e13];
    i2.push([a2, r2]), r2 += n2[e13].length, r2 += n2[e13 + 1]?.length || 0;
  }
  return i2;
}
var bt = { light: `#333333`, dark: `#bbbbbb` }, xt = { light: `#fffffe`, dark: `#1e1e1e` }, St = `__shiki_resolved`;
function Ct(e12) {
  if (e12?.[St]) return e12;
  let t2 = { ...e12 };
  t2.tokenColors && !t2.settings && (t2.settings = t2.tokenColors, delete t2.tokenColors), t2.type || (t2.type = `dark`), t2.colorReplacements = { ...t2.colorReplacements }, t2.settings || (t2.settings = []);
  let { bg: n2, fg: r2 } = t2;
  if (!n2 || !r2) {
    let e13 = t2.settings ? t2.settings.find((e14) => !e14.name && !e14.scope) : void 0;
    e13?.settings?.foreground && (r2 = e13.settings.foreground), e13?.settings?.background && (n2 = e13.settings.background), !r2 && t2?.colors?.[`editor.foreground`] && (r2 = t2.colors[`editor.foreground`]), !n2 && t2?.colors?.[`editor.background`] && (n2 = t2.colors[`editor.background`]), r2 || (r2 = t2.type === `light` ? bt.light : bt.dark), n2 || (n2 = t2.type === `light` ? xt.light : xt.dark), t2.fg = r2, t2.bg = n2;
  }
  t2.settings[0] && t2.settings[0].settings && !t2.settings[0].scope || t2.settings.unshift({ settings: { foreground: t2.fg, background: t2.bg } });
  let i2 = 0, a2 = /* @__PURE__ */ new Map();
  function o2(e13) {
    if (a2.has(e13)) return a2.get(e13);
    i2 += 1;
    let n3 = `#${i2.toString(16).padStart(8, `0`).toLowerCase()}`;
    return t2.colorReplacements?.[`#${n3}`] ? o2(e13) : (a2.set(e13, n3), n3);
  }
  t2.settings = t2.settings.map((e13) => {
    let n3 = e13.settings?.foreground && !e13.settings.foreground.startsWith(`#`), r3 = e13.settings?.background && !e13.settings.background.startsWith(`#`);
    if (!n3 && !r3) return e13;
    let i3 = { ...e13, settings: { ...e13.settings } };
    if (n3) {
      let n4 = o2(e13.settings.foreground);
      t2.colorReplacements[n4] = e13.settings.foreground, i3.settings.foreground = n4;
    }
    if (r3) {
      let n4 = o2(e13.settings.background);
      t2.colorReplacements[n4] = e13.settings.background, i3.settings.background = n4;
    }
    return i3;
  });
  for (let e13 of Object.keys(t2.colors || {})) if ((e13 === `editor.foreground` || e13 === `editor.background` || e13.startsWith(`terminal.ansi`)) && !t2.colors[e13]?.startsWith(`#`)) {
    let n3 = o2(t2.colors[e13]);
    t2.colorReplacements[n3] = t2.colors[e13], t2.colors[e13] = n3;
  }
  return Object.defineProperty(t2, St, { enumerable: false, writable: false, value: true }), t2;
}
async function wt(e12) {
  return [...new Set((await Promise.all(e12.filter((e13) => !ht(e13)).map(async (e13) => await pt(e13).then((e14) => Array.isArray(e14) ? e14 : [e14])))).flat())];
}
async function Tt(e12) {
  return (await Promise.all(e12.map(async (e13) => _t(e13) ? null : Ct(await pt(e13))))).filter((e13) => !!e13);
}
function Et(e12, t2) {
  if (!t2) return e12;
  if (t2[e12]) {
    let n2 = /* @__PURE__ */ new Set([e12]);
    for (; t2[e12]; ) {
      if (e12 = t2[e12], n2.has(e12)) throw new a(`Circular alias \`${[...n2].join(` -> `)} -> ${e12}\``);
      n2.add(e12);
    }
  }
  return e12;
}
var Dt = class extends ut {
  constructor(e12, t2, n2, r2 = {}) {
    super(e12);
    __publicField(this, "_resolver");
    __publicField(this, "_themes");
    __publicField(this, "_langs");
    __publicField(this, "_alias");
    __publicField(this, "_resolvedThemes", /* @__PURE__ */ new Map());
    __publicField(this, "_resolvedGrammars", /* @__PURE__ */ new Map());
    __publicField(this, "_langMap", /* @__PURE__ */ new Map());
    __publicField(this, "_langGraph", /* @__PURE__ */ new Map());
    __publicField(this, "_textmateThemeCache", /* @__PURE__ */ new WeakMap());
    __publicField(this, "_loadedThemesCache", null);
    __publicField(this, "_loadedLanguagesCache", null);
    this._resolver = e12, this._themes = t2, this._langs = n2, this._alias = r2, this._themes.map((e13) => this.loadTheme(e13)), this.loadLanguages(this._langs);
  }
  getTheme(e12) {
    return typeof e12 == `string` ? this._resolvedThemes.get(e12) : this.loadTheme(e12);
  }
  loadTheme(e12) {
    let t2 = Ct(e12);
    return t2.name && (this._resolvedThemes.set(t2.name, t2), this._loadedThemesCache = null), t2;
  }
  getLoadedThemes() {
    return this._loadedThemesCache || (this._loadedThemesCache = [...this._resolvedThemes.keys()]), this._loadedThemesCache;
  }
  setTheme(e12) {
    let t2 = this._textmateThemeCache.get(e12);
    t2 || (t2 = y.createFromRawTheme(e12), this._textmateThemeCache.set(e12, t2)), this._syncRegistry.setTheme(t2);
  }
  getGrammar(e12) {
    return e12 = Et(e12, this._alias), this._resolvedGrammars.get(e12);
  }
  loadLanguage(e12) {
    if (this.getGrammar(e12.name)) return;
    let t2 = new Set([...this._langMap.values()].filter((t3) => t3.embeddedLangsLazy?.includes(e12.name)));
    this._resolver.addLanguage(e12);
    let n2 = { balancedBracketSelectors: e12.balancedBracketSelectors || [`*`], unbalancedBracketSelectors: e12.unbalancedBracketSelectors || [] };
    this._syncRegistry._rawGrammars.set(e12.scopeName, e12);
    let r2 = this.loadGrammarWithConfiguration(e12.scopeName, 1, n2);
    if (r2.name = e12.name, this._resolvedGrammars.set(e12.name, r2), e12.aliases && e12.aliases.forEach((t3) => {
      this._alias[t3] = e12.name;
    }), this._loadedLanguagesCache = null, t2.size) for (let e13 of t2) this._resolvedGrammars.delete(e13.name), this._loadedLanguagesCache = null, this._syncRegistry?._injectionGrammars?.delete(e13.scopeName), this._syncRegistry?._grammars?.delete(e13.scopeName), this.loadLanguage(this._langMap.get(e13.name));
  }
  dispose() {
    super.dispose(), this._resolvedThemes.clear(), this._resolvedGrammars.clear(), this._langMap.clear(), this._langGraph.clear(), this._loadedThemesCache = null;
  }
  loadLanguages(e12) {
    for (let t3 of e12) this.resolveEmbeddedLanguages(t3);
    let t2 = [...this._langGraph.entries()], n2 = t2.filter(([e13, t3]) => !t3);
    if (n2.length) {
      let e13 = t2.filter(([e14, t3]) => t3 ? (t3.embeddedLanguages || t3.embeddedLangs)?.some((e15) => n2.map(([e16]) => e16).includes(e15)) : false).filter((e14) => !n2.includes(e14));
      throw new a(`Missing languages ${n2.map(([e14]) => `\`${e14}\``).join(`, `)}, required by ${e13.map(([e14]) => `\`${e14}\``).join(`, `)}`);
    }
    for (let [e13, n3] of t2) this._resolver.addLanguage(n3);
    for (let [e13, n3] of t2) this.loadLanguage(n3);
  }
  getLoadedLanguages() {
    return this._loadedLanguagesCache || (this._loadedLanguagesCache = [.../* @__PURE__ */ new Set([...this._resolvedGrammars.keys(), ...Object.keys(this._alias)])]), this._loadedLanguagesCache;
  }
  resolveEmbeddedLanguages(e12) {
    this._langMap.set(e12.name, e12), this._langGraph.set(e12.name, e12);
    let t2 = e12.embeddedLanguages ?? e12.embeddedLangs;
    if (t2) for (let e13 of t2) this._langGraph.set(e13, this._langMap.get(e13));
  }
}, Ot = class {
  constructor(e12, t2) {
    __publicField(this, "_langs", /* @__PURE__ */ new Map());
    __publicField(this, "_scopeToLang", /* @__PURE__ */ new Map());
    __publicField(this, "_injections", /* @__PURE__ */ new Map());
    __publicField(this, "_onigLib");
    this._onigLib = { createOnigScanner: (t3) => e12.createScanner(t3), createOnigString: (t3) => e12.createString(t3) }, t2.forEach((e13) => this.addLanguage(e13));
  }
  get onigLib() {
    return this._onigLib;
  }
  getLangRegistration(e12) {
    return this._langs.get(e12);
  }
  loadGrammar(e12) {
    return this._scopeToLang.get(e12);
  }
  addLanguage(e12) {
    this._langs.set(e12.name, e12), e12.aliases && e12.aliases.forEach((t2) => {
      this._langs.set(t2, e12);
    }), this._scopeToLang.set(e12.scopeName, e12), e12.injectTo && e12.injectTo.forEach((t2) => {
      this._injections.get(t2) || this._injections.set(t2, []), this._injections.get(t2).push(e12.scopeName);
    });
  }
  getInjections(e12) {
    let t2 = e12.split(`.`), n2 = [];
    for (let e13 = 1; e13 <= t2.length; e13++) {
      let r2 = t2.slice(0, e13).join(`.`);
      n2 = [...n2, ...this._injections.get(r2) || []];
    }
    return n2;
  }
}, N = 0;
function kt(e12) {
  N += 1, e12.warnings !== false && N >= 10 && N % 10 == 0 && console.warn(`[Shiki] ${N} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);
  let t2 = false;
  if (!e12.engine) throw new a("`engine` option is required for synchronous mode");
  let n2 = (e12.langs || []).flat(1), r2 = (e12.themes || []).flat(1).map(Ct), i2 = new Dt(new Ot(e12.engine, n2), r2, n2, e12.langAlias), o2;
  function s2(t3) {
    return Et(t3, e12.langAlias);
  }
  function c2(e13) {
    _2();
    let t3 = i2.getGrammar(typeof e13 == `string` ? e13 : e13.name);
    if (!t3) throw new a(`Language \`${e13}\` not found, you may need to load it first`);
    return t3;
  }
  function l2(e13) {
    if (e13 === `none`) return { bg: ``, fg: ``, name: `none`, settings: [], type: `dark` };
    _2();
    let t3 = i2.getTheme(e13);
    if (!t3) throw new a(`Theme \`${e13}\` not found, you may need to load it first`);
    return t3;
  }
  function u2(e13) {
    _2();
    let t3 = l2(e13);
    return o2 !== e13 && (i2.setTheme(t3), o2 = e13), { theme: t3, colorMap: i2.getColorMap() };
  }
  function d2() {
    return _2(), i2.getLoadedThemes();
  }
  function f2() {
    return _2(), i2.getLoadedLanguages();
  }
  function p2(...e13) {
    _2(), i2.loadLanguages(e13.flat(1));
  }
  async function m2(...e13) {
    return p2(await wt(e13));
  }
  function h2(...e13) {
    _2();
    for (let t3 of e13.flat(1)) i2.loadTheme(t3);
  }
  async function g2(...e13) {
    return _2(), h2(await Tt(e13));
  }
  function _2() {
    if (t2) throw new a(`Shiki instance has been disposed`);
  }
  function v2() {
    t2 || (t2 = true, i2.dispose(), --N);
  }
  return { setTheme: u2, getTheme: l2, getLanguage: c2, getLoadedThemes: d2, getLoadedLanguages: f2, resolveLangAlias: s2, loadLanguage: m2, loadLanguageSync: p2, loadTheme: g2, loadThemeSync: h2, dispose: v2, [Symbol.dispose]: v2 };
}
async function At(e12) {
  e12.engine || console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");
  let [t2, n2, r2] = await Promise.all([Tt(e12.themes || []), wt(e12.langs || []), e12.engine]);
  return kt({ ...e12, themes: t2, langs: n2, engine: r2 });
}
var jt = /* @__PURE__ */ new WeakMap();
function Mt(e12, t2) {
  jt.set(e12, t2);
}
function P(e12) {
  return jt.get(e12);
}
var F = class e9 {
  constructor(...e12) {
    __publicField(this, "_stacks", {});
    __publicField(this, "lang");
    if (e12.length === 2) {
      let [t2, n2] = e12;
      this.lang = n2, this._stacks = t2;
    } else {
      let [t2, n2, r2] = e12;
      this.lang = n2, this._stacks = { [r2]: t2 };
    }
  }
  get themes() {
    return Object.keys(this._stacks);
  }
  get theme() {
    return this.themes[0];
  }
  get _stack() {
    return this._stacks[this.theme];
  }
  static initial(t2, n2) {
    return new e9(Object.fromEntries(ft(n2).map((e12) => [e12, dt])), t2);
  }
  getInternalStack(e12 = this.theme) {
    return this._stacks[e12];
  }
  getScopes(e12 = this.theme) {
    return Nt(this._stacks[e12]);
  }
  toJSON() {
    return { lang: this.lang, theme: this.theme, themes: this.themes, scopes: this.getScopes() };
  }
};
function Nt(e12) {
  let t2 = [], n2 = /* @__PURE__ */ new Set();
  function r2(e13) {
    if (n2.has(e13)) return;
    n2.add(e13);
    let i2 = e13?.nameScopesList?.scopeName;
    i2 && t2.push(i2), e13.parent && r2(e13.parent);
  }
  return r2(e12), t2;
}
function Pt(e12, t2) {
  if (!(e12 instanceof F)) throw new a(`Invalid grammar state`);
  return e12.getInternalStack(t2);
}
var Ft = /,/, It = / /;
function Lt(e12, t2, n2 = {}) {
  let { theme: r2 = e12.getLoadedThemes()[0] } = n2;
  if (mt(e12.resolveLangAlias(n2.lang || `text`)) || gt(r2)) return yt(t2).map((e13) => [{ content: e13[0], offset: e13[1] }]);
  let { theme: i2, colorMap: o2 } = e12.setTheme(r2), s2 = e12.getLanguage(n2.lang || `text`);
  if (n2.grammarState) {
    if (n2.grammarState.lang !== s2.name) throw new a(`Grammar state language "${n2.grammarState.lang}" does not match highlight language "${s2.name}"`);
    if (!n2.grammarState.themes.includes(i2.name)) throw new a(`Grammar state themes "${n2.grammarState.themes}" do not contain highlight theme "${i2.name}"`);
  }
  return zt(t2, s2, i2, o2, n2);
}
function Rt(...e12) {
  if (e12.length === 2) return P(e12[1]);
  let [t2, n2, r2 = {}] = e12, { lang: i2 = `text`, theme: o2 = t2.getLoadedThemes()[0] } = r2;
  if (mt(i2) || gt(o2)) throw new a(`Plain language does not have grammar state`);
  if (i2 === `ansi`) throw new a(`ANSI language does not have grammar state`);
  let { theme: s2, colorMap: c2 } = t2.setTheme(o2), l2 = t2.getLanguage(i2);
  return new F(Bt(n2, l2, s2, c2, r2).stateStack, l2.name, s2.name);
}
function zt(e12, t2, n2, r2, i2) {
  let a2 = Bt(e12, t2, n2, r2, i2), o2 = new F(a2.stateStack, t2.name, n2.name);
  return Mt(a2.tokens, o2), a2.tokens;
}
function Bt(e12, t2, n2, r2, i2) {
  let a2 = j(n2, i2), { tokenizeMaxLineLength: o2 = 0, tokenizeTimeLimit: s2 = 500 } = i2, c2 = yt(e12), l2 = i2.grammarState ? Pt(i2.grammarState, n2.name) ?? dt : i2.grammarContextCode == null ? dt : Bt(i2.grammarContextCode, t2, n2, r2, { ...i2, grammarState: void 0, grammarContextCode: void 0 }).stateStack, u2 = [], d2 = [];
  for (let e13 = 0, f2 = c2.length; e13 < f2; e13++) {
    let [f3, p2] = c2[e13];
    if (f3 === ``) {
      u2 = [], d2.push([]);
      continue;
    }
    if (o2 > 0 && f3.length >= o2) {
      u2 = [], d2.push([{ content: f3, offset: p2, color: ``, fontStyle: 0 }]);
      continue;
    }
    let m2, h2, g2;
    i2.includeExplanation && (m2 = t2.tokenizeLine(f3, l2, s2), h2 = m2.tokens, g2 = 0);
    let _2 = t2.tokenizeLine2(f3, l2, s2), v2 = _2.tokens.length / 2;
    for (let e14 = 0; e14 < v2; e14++) {
      let t3 = _2.tokens[2 * e14], o3 = e14 + 1 < v2 ? _2.tokens[2 * e14 + 2] : f3.length;
      if (t3 === o3) continue;
      let s3 = _2.tokens[2 * e14 + 1], c3 = M(r2[x.getForeground(s3)], a2), l3 = x.getFontStyle(s3), d3 = { content: f3.substring(t3, o3), offset: p2 + t3, color: c3, fontStyle: l3 };
      if (i2.includeExplanation) {
        let e15 = [];
        if (i2.includeExplanation !== `scopeName`) for (let t4 of n2.settings) {
          let n3;
          switch (typeof t4.scope) {
            case `string`:
              n3 = t4.scope.split(Ft).map((e16) => e16.trim());
              break;
            case `object`:
              n3 = t4.scope;
              break;
            default:
              continue;
          }
          e15.push({ settings: t4, selectors: n3.map((e16) => e16.split(It)) });
        }
        d3.explanation = [];
        let r3 = 0;
        for (; t3 + r3 < o3; ) {
          let t4 = h2[g2], n3 = f3.substring(t4.startIndex, t4.endIndex);
          r3 += n3.length, d3.explanation.push({ content: n3, scopes: i2.includeExplanation === `scopeName` ? Vt(t4.scopes) : Ht(e15, t4.scopes) }), g2 += 1;
        }
      }
      u2.push(d3);
    }
    d2.push(u2), u2 = [], l2 = _2.ruleStack;
  }
  return { tokens: d2, stateStack: l2 };
}
function Vt(e12) {
  return e12.map((e13) => ({ scopeName: e13 }));
}
function Ht(e12, t2) {
  let n2 = [];
  for (let r2 = 0, i2 = t2.length; r2 < i2; r2++) {
    let i3 = t2[r2];
    n2[r2] = { scopeName: i3, themeMatches: Gt(e12, i3, t2.slice(0, r2)) };
  }
  return n2;
}
function Ut(e12, t2) {
  return e12 === t2 || t2.substring(0, e12.length) === e12 && t2[e12.length] === `.`;
}
function Wt(e12, t2, n2) {
  if (!Ut(e12.at(-1), t2)) return false;
  let r2 = e12.length - 2, i2 = n2.length - 1;
  for (; r2 >= 0 && i2 >= 0; ) Ut(e12[r2], n2[i2]) && --r2, --i2;
  return r2 === -1;
}
function Gt(e12, t2, n2) {
  let r2 = [];
  for (let { selectors: i2, settings: a2 } of e12) for (let e13 of i2) if (Wt(e13, t2, n2)) {
    r2.push(a2);
    break;
  }
  return r2;
}
function Kt(e12, t2, n2, r2 = Lt) {
  let i2 = Object.entries(n2.themes).filter((e13) => e13[1]).map((e13) => ({ color: e13[0], theme: e13[1] })), a2 = i2.map((i3) => {
    let a3 = r2(e12, t2, { ...n2, theme: i3.theme });
    return { tokens: a3, state: P(a3), theme: typeof i3.theme == `string` ? i3.theme : i3.theme.name };
  }), o2 = qt(...a2.map((e13) => e13.tokens)), s2 = o2[0].map((e13, t3) => e13.map((e14, r3) => {
    let a3 = { content: e14.content, variants: {}, offset: e14.offset };
    return `includeExplanation` in n2 && n2.includeExplanation && (a3.explanation = e14.explanation), o2.forEach((e15, n3) => {
      let { content: o3, explanation: s3, offset: c3, ...l2 } = e15[t3][r3];
      a3.variants[i2[n3].color] = l2;
    }), a3;
  })), c2 = a2[0].state ? new F(Object.fromEntries(a2.map((e13) => [e13.theme, e13.state?.getInternalStack(e13.theme)])), a2[0].state.lang) : void 0;
  return c2 && Mt(s2, c2), s2;
}
function qt(...e12) {
  let t2 = e12.map(() => []), n2 = e12.length;
  for (let r2 = 0; r2 < e12[0].length; r2++) {
    let i2 = e12.map((e13) => e13[r2]), a2 = t2.map(() => []);
    t2.forEach((e13, t3) => e13.push(a2[t3]));
    let o2 = i2.map(() => 0), s2 = i2.map((e13) => e13[0]);
    for (; s2.every((e13) => e13); ) {
      let e13 = Math.min(...s2.map((e14) => e14.content.length));
      for (let t3 = 0; t3 < n2; t3++) {
        let n3 = s2[t3];
        n3.content.length === e13 ? (a2[t3].push(n3), o2[t3] += 1, s2[t3] = i2[t3][o2[t3]]) : (a2[t3].push({ ...n3, content: n3.content.slice(0, e13) }), s2[t3] = { ...n3, content: n3.content.slice(e13), offset: n3.offset + e13 });
      }
    }
  }
  return t2;
}
var Jt = [`area`, `base`, `basefont`, `bgsound`, `br`, `col`, `command`, `embed`, `frame`, `hr`, `image`, `img`, `input`, `keygen`, `link`, `meta`, `param`, `source`, `track`, `wbr`], I = class {
  constructor(e12, t2, n2) {
    this.normal = t2, this.property = e12, n2 && (this.space = n2);
  }
};
I.prototype.normal = {}, I.prototype.property = {}, I.prototype.space = void 0;
function Yt(e12, t2) {
  let n2 = {}, r2 = {};
  for (let t3 of e12) Object.assign(n2, t3.property), Object.assign(r2, t3.normal);
  return new I(n2, r2, t2);
}
function Xt(e12) {
  return e12.toLowerCase();
}
var L = class {
  constructor(e12, t2) {
    this.attribute = t2, this.property = e12;
  }
};
L.prototype.attribute = ``, L.prototype.booleanish = false, L.prototype.boolean = false, L.prototype.commaOrSpaceSeparated = false, L.prototype.commaSeparated = false, L.prototype.defined = false, L.prototype.mustUseProperty = false, L.prototype.number = false, L.prototype.overloadedBoolean = false, L.prototype.property = ``, L.prototype.spaceSeparated = false, L.prototype.space = void 0;
var Zt = e({ boolean: () => R, booleanish: () => z, commaOrSpaceSeparated: () => U, commaSeparated: () => H, number: () => B, overloadedBoolean: () => $t, spaceSeparated: () => V }), Qt = 0, R = W(), z = W(), $t = W(), B = W(), V = W(), H = W(), U = W();
function W() {
  return 2 ** ++Qt;
}
var en = Object.keys(Zt), tn = class extends L {
  constructor(e12, t2, n2, r2) {
    let i2 = -1;
    if (super(e12, t2), nn(this, `space`, r2), typeof n2 == `number`) for (; ++i2 < en.length; ) {
      let e13 = en[i2];
      nn(this, en[i2], (n2 & Zt[e13]) === Zt[e13]);
    }
  }
};
tn.prototype.defined = true;
function nn(e12, t2, n2) {
  n2 && (e12[t2] = n2);
}
function G(e12) {
  let t2 = {}, n2 = {};
  for (let [r2, i2] of Object.entries(e12.properties)) {
    let a2 = new tn(r2, e12.transform(e12.attributes || {}, r2), i2, e12.space);
    e12.mustUseProperty && e12.mustUseProperty.includes(r2) && (a2.mustUseProperty = true), t2[r2] = a2, n2[Xt(r2)] = r2, n2[Xt(a2.attribute)] = r2;
  }
  return new I(t2, n2, e12.space);
}
var rn = G({ properties: { ariaActiveDescendant: null, ariaAtomic: z, ariaAutoComplete: null, ariaBusy: z, ariaChecked: z, ariaColCount: B, ariaColIndex: B, ariaColSpan: B, ariaControls: V, ariaCurrent: null, ariaDescribedBy: V, ariaDetails: null, ariaDisabled: z, ariaDropEffect: V, ariaErrorMessage: null, ariaExpanded: z, ariaFlowTo: V, ariaGrabbed: z, ariaHasPopup: null, ariaHidden: z, ariaInvalid: null, ariaKeyShortcuts: null, ariaLabel: null, ariaLabelledBy: V, ariaLevel: B, ariaLive: null, ariaModal: z, ariaMultiLine: z, ariaMultiSelectable: z, ariaOrientation: null, ariaOwns: V, ariaPlaceholder: null, ariaPosInSet: B, ariaPressed: z, ariaReadOnly: z, ariaRelevant: null, ariaRequired: z, ariaRoleDescription: V, ariaRowCount: B, ariaRowIndex: B, ariaRowSpan: B, ariaSelected: z, ariaSetSize: B, ariaSort: null, ariaValueMax: B, ariaValueMin: B, ariaValueNow: B, ariaValueText: null, role: null }, transform(e12, t2) {
  return t2 === `role` ? t2 : `aria-` + t2.slice(4).toLowerCase();
} });
function an(e12, t2) {
  return t2 in e12 ? e12[t2] : t2;
}
function on(e12, t2) {
  return an(e12, t2.toLowerCase());
}
var sn = G({ attributes: { acceptcharset: `accept-charset`, classname: `class`, htmlfor: `for`, httpequiv: `http-equiv` }, mustUseProperty: [`checked`, `multiple`, `muted`, `selected`], properties: { abbr: null, accept: H, acceptCharset: V, accessKey: V, action: null, allow: null, allowFullScreen: R, allowPaymentRequest: R, allowUserMedia: R, alpha: R, alt: null, as: null, async: R, autoCapitalize: null, autoComplete: V, autoFocus: R, autoPlay: R, blocking: V, capture: null, charSet: null, checked: R, cite: null, className: V, closedBy: null, colorSpace: null, cols: B, colSpan: B, command: null, commandFor: null, content: null, contentEditable: z, controls: R, controlsList: V, coords: B | H, crossOrigin: null, data: null, dateTime: null, decoding: null, default: R, defer: R, dir: null, dirName: null, disabled: R, download: $t, draggable: z, encType: null, enterKeyHint: null, fetchPriority: null, form: null, formAction: null, formEncType: null, formMethod: null, formNoValidate: R, formTarget: null, headers: V, height: B, hidden: $t, high: B, href: null, hrefLang: null, htmlFor: V, httpEquiv: V, id: null, imageSizes: null, imageSrcSet: null, inert: R, inputMode: null, integrity: null, is: null, isMap: R, itemId: null, itemProp: V, itemRef: V, itemScope: R, itemType: V, kind: null, label: null, lang: null, language: null, list: null, loading: null, loop: R, low: B, manifest: null, max: null, maxLength: B, media: null, method: null, min: null, minLength: B, multiple: R, muted: R, name: null, nonce: null, noModule: R, noValidate: R, onAbort: null, onAfterPrint: null, onAuxClick: null, onBeforeMatch: null, onBeforePrint: null, onBeforeToggle: null, onBeforeUnload: null, onBlur: null, onCancel: null, onCanPlay: null, onCanPlayThrough: null, onChange: null, onClick: null, onClose: null, onContextLost: null, onContextMenu: null, onContextRestored: null, onCopy: null, onCueChange: null, onCut: null, onDblClick: null, onDrag: null, onDragEnd: null, onDragEnter: null, onDragExit: null, onDragLeave: null, onDragOver: null, onDragStart: null, onDrop: null, onDurationChange: null, onEmptied: null, onEnded: null, onError: null, onFocus: null, onFormData: null, onHashChange: null, onInput: null, onInvalid: null, onKeyDown: null, onKeyPress: null, onKeyUp: null, onLanguageChange: null, onLoad: null, onLoadedData: null, onLoadedMetadata: null, onLoadEnd: null, onLoadStart: null, onMessage: null, onMessageError: null, onMouseDown: null, onMouseEnter: null, onMouseLeave: null, onMouseMove: null, onMouseOut: null, onMouseOver: null, onMouseUp: null, onOffline: null, onOnline: null, onPageHide: null, onPageShow: null, onPaste: null, onPause: null, onPlay: null, onPlaying: null, onPopState: null, onProgress: null, onRateChange: null, onRejectionHandled: null, onReset: null, onResize: null, onScroll: null, onScrollEnd: null, onSecurityPolicyViolation: null, onSeeked: null, onSeeking: null, onSelect: null, onSlotChange: null, onStalled: null, onStorage: null, onSubmit: null, onSuspend: null, onTimeUpdate: null, onToggle: null, onUnhandledRejection: null, onUnload: null, onVolumeChange: null, onWaiting: null, onWheel: null, open: R, optimum: B, pattern: null, ping: V, placeholder: null, playsInline: R, popover: null, popoverTarget: null, popoverTargetAction: null, poster: null, preload: null, readOnly: R, referrerPolicy: null, rel: V, required: R, reversed: R, rows: B, rowSpan: B, sandbox: V, scope: null, scoped: R, seamless: R, selected: R, shadowRootClonable: R, shadowRootCustomElementRegistry: R, shadowRootDelegatesFocus: R, shadowRootMode: null, shadowRootSerializable: R, shape: null, size: B, sizes: null, slot: null, span: B, spellCheck: z, src: null, srcDoc: null, srcLang: null, srcSet: null, start: B, step: null, style: null, tabIndex: B, target: null, title: null, translate: null, type: null, typeMustMatch: R, useMap: null, value: z, width: B, wrap: null, writingSuggestions: null, align: null, aLink: null, archive: V, axis: null, background: null, bgColor: null, border: B, borderColor: null, bottomMargin: B, cellPadding: null, cellSpacing: null, char: null, charOff: null, classId: null, clear: null, code: null, codeBase: null, codeType: null, color: null, compact: R, declare: R, event: null, face: null, frame: null, frameBorder: null, hSpace: B, leftMargin: B, link: null, longDesc: null, lowSrc: null, marginHeight: B, marginWidth: B, noResize: R, noHref: R, noShade: R, noWrap: R, object: null, profile: null, prompt: null, rev: null, rightMargin: B, rules: null, scheme: null, scrolling: z, standby: null, summary: null, text: null, topMargin: B, valueType: null, version: null, vAlign: null, vLink: null, vSpace: B, allowTransparency: null, autoCorrect: null, autoSave: null, credentialless: R, disablePictureInPicture: R, disableRemotePlayback: R, exportParts: H, part: V, prefix: null, property: null, results: B, security: null, unselectable: null }, space: `html`, transform: on }), cn = G({ attributes: { accentHeight: `accent-height`, alignmentBaseline: `alignment-baseline`, arabicForm: `arabic-form`, baselineShift: `baseline-shift`, capHeight: `cap-height`, className: `class`, clipPath: `clip-path`, clipRule: `clip-rule`, colorInterpolation: `color-interpolation`, colorInterpolationFilters: `color-interpolation-filters`, colorProfile: `color-profile`, colorRendering: `color-rendering`, crossOrigin: `crossorigin`, dataType: `datatype`, dominantBaseline: `dominant-baseline`, enableBackground: `enable-background`, fillOpacity: `fill-opacity`, fillRule: `fill-rule`, floodColor: `flood-color`, floodOpacity: `flood-opacity`, fontFamily: `font-family`, fontSize: `font-size`, fontSizeAdjust: `font-size-adjust`, fontStretch: `font-stretch`, fontStyle: `font-style`, fontVariant: `font-variant`, fontWeight: `font-weight`, glyphName: `glyph-name`, glyphOrientationHorizontal: `glyph-orientation-horizontal`, glyphOrientationVertical: `glyph-orientation-vertical`, hrefLang: `hreflang`, horizAdvX: `horiz-adv-x`, horizOriginX: `horiz-origin-x`, horizOriginY: `horiz-origin-y`, imageRendering: `image-rendering`, letterSpacing: `letter-spacing`, lightingColor: `lighting-color`, markerEnd: `marker-end`, markerMid: `marker-mid`, markerStart: `marker-start`, maskType: `mask-type`, navDown: `nav-down`, navDownLeft: `nav-down-left`, navDownRight: `nav-down-right`, navLeft: `nav-left`, navNext: `nav-next`, navPrev: `nav-prev`, navRight: `nav-right`, navUp: `nav-up`, navUpLeft: `nav-up-left`, navUpRight: `nav-up-right`, onAbort: `onabort`, onActivate: `onactivate`, onAfterPrint: `onafterprint`, onBeforePrint: `onbeforeprint`, onBegin: `onbegin`, onCancel: `oncancel`, onCanPlay: `oncanplay`, onCanPlayThrough: `oncanplaythrough`, onChange: `onchange`, onClick: `onclick`, onClose: `onclose`, onCopy: `oncopy`, onCueChange: `oncuechange`, onCut: `oncut`, onDblClick: `ondblclick`, onDrag: `ondrag`, onDragEnd: `ondragend`, onDragEnter: `ondragenter`, onDragExit: `ondragexit`, onDragLeave: `ondragleave`, onDragOver: `ondragover`, onDragStart: `ondragstart`, onDrop: `ondrop`, onDurationChange: `ondurationchange`, onEmptied: `onemptied`, onEnd: `onend`, onEnded: `onended`, onError: `onerror`, onFocus: `onfocus`, onFocusIn: `onfocusin`, onFocusOut: `onfocusout`, onHashChange: `onhashchange`, onInput: `oninput`, onInvalid: `oninvalid`, onKeyDown: `onkeydown`, onKeyPress: `onkeypress`, onKeyUp: `onkeyup`, onLoad: `onload`, onLoadedData: `onloadeddata`, onLoadedMetadata: `onloadedmetadata`, onLoadStart: `onloadstart`, onMessage: `onmessage`, onMouseDown: `onmousedown`, onMouseEnter: `onmouseenter`, onMouseLeave: `onmouseleave`, onMouseMove: `onmousemove`, onMouseOut: `onmouseout`, onMouseOver: `onmouseover`, onMouseUp: `onmouseup`, onMouseWheel: `onmousewheel`, onOffline: `onoffline`, onOnline: `ononline`, onPageHide: `onpagehide`, onPageShow: `onpageshow`, onPaste: `onpaste`, onPause: `onpause`, onPlay: `onplay`, onPlaying: `onplaying`, onPopState: `onpopstate`, onProgress: `onprogress`, onRateChange: `onratechange`, onRepeat: `onrepeat`, onReset: `onreset`, onResize: `onresize`, onScroll: `onscroll`, onSeeked: `onseeked`, onSeeking: `onseeking`, onSelect: `onselect`, onShow: `onshow`, onStalled: `onstalled`, onStorage: `onstorage`, onSubmit: `onsubmit`, onSuspend: `onsuspend`, onTimeUpdate: `ontimeupdate`, onToggle: `ontoggle`, onUnload: `onunload`, onVolumeChange: `onvolumechange`, onWaiting: `onwaiting`, onZoom: `onzoom`, overlinePosition: `overline-position`, overlineThickness: `overline-thickness`, paintOrder: `paint-order`, panose1: `panose-1`, pointerEvents: `pointer-events`, referrerPolicy: `referrerpolicy`, renderingIntent: `rendering-intent`, shapeRendering: `shape-rendering`, stopColor: `stop-color`, stopOpacity: `stop-opacity`, strikethroughPosition: `strikethrough-position`, strikethroughThickness: `strikethrough-thickness`, strokeDashArray: `stroke-dasharray`, strokeDashOffset: `stroke-dashoffset`, strokeLineCap: `stroke-linecap`, strokeLineJoin: `stroke-linejoin`, strokeMiterLimit: `stroke-miterlimit`, strokeOpacity: `stroke-opacity`, strokeWidth: `stroke-width`, tabIndex: `tabindex`, textAnchor: `text-anchor`, textDecoration: `text-decoration`, textRendering: `text-rendering`, transformOrigin: `transform-origin`, typeOf: `typeof`, underlinePosition: `underline-position`, underlineThickness: `underline-thickness`, unicodeBidi: `unicode-bidi`, unicodeRange: `unicode-range`, unitsPerEm: `units-per-em`, vAlphabetic: `v-alphabetic`, vHanging: `v-hanging`, vIdeographic: `v-ideographic`, vMathematical: `v-mathematical`, vectorEffect: `vector-effect`, vertAdvY: `vert-adv-y`, vertOriginX: `vert-origin-x`, vertOriginY: `vert-origin-y`, wordSpacing: `word-spacing`, writingMode: `writing-mode`, xHeight: `x-height`, playbackOrder: `playbackorder`, timelineBegin: `timelinebegin` }, properties: { about: U, accentHeight: B, accumulate: null, additive: null, alignmentBaseline: null, alphabetic: B, amplitude: B, arabicForm: null, ascent: B, attributeName: null, attributeType: null, azimuth: B, bandwidth: null, baselineShift: null, baseFrequency: null, baseProfile: null, bbox: null, begin: null, bias: B, by: null, calcMode: null, capHeight: B, className: V, clip: null, clipPath: null, clipPathUnits: null, clipRule: null, color: null, colorInterpolation: null, colorInterpolationFilters: null, colorProfile: null, colorRendering: null, content: null, contentScriptType: null, contentStyleType: null, crossOrigin: null, cursor: null, cx: null, cy: null, d: null, dataType: null, defaultAction: null, descent: B, diffuseConstant: B, direction: null, display: null, dur: null, divisor: B, dominantBaseline: null, download: R, dx: null, dy: null, edgeMode: null, editable: null, elevation: B, enableBackground: null, end: null, event: null, exponent: B, externalResourcesRequired: null, fill: null, fillOpacity: B, fillRule: null, filter: null, filterRes: null, filterUnits: null, floodColor: null, floodOpacity: null, focusable: null, focusHighlight: null, fontFamily: null, fontSize: null, fontSizeAdjust: null, fontStretch: null, fontStyle: null, fontVariant: null, fontWeight: null, format: null, fr: null, from: null, fx: null, fy: null, g1: H, g2: H, glyphName: H, glyphOrientationHorizontal: null, glyphOrientationVertical: null, glyphRef: null, gradientTransform: null, gradientUnits: null, handler: null, hanging: B, hatchContentUnits: null, hatchUnits: null, height: null, href: null, hrefLang: null, horizAdvX: B, horizOriginX: B, horizOriginY: B, id: null, ideographic: B, imageRendering: null, initialVisibility: null, in: null, in2: null, intercept: B, k: B, k1: B, k2: B, k3: B, k4: B, kernelMatrix: U, kernelUnitLength: null, keyPoints: null, keySplines: null, keyTimes: null, kerning: null, lang: null, lengthAdjust: null, letterSpacing: null, lightingColor: null, limitingConeAngle: B, local: null, markerEnd: null, markerMid: null, markerStart: null, markerHeight: null, markerUnits: null, markerWidth: null, mask: null, maskContentUnits: null, maskType: null, maskUnits: null, mathematical: null, max: null, media: null, mediaCharacterEncoding: null, mediaContentEncodings: null, mediaSize: B, mediaTime: null, method: null, min: null, mode: null, name: null, navDown: null, navDownLeft: null, navDownRight: null, navLeft: null, navNext: null, navPrev: null, navRight: null, navUp: null, navUpLeft: null, navUpRight: null, numOctaves: null, observer: null, offset: null, onAbort: null, onActivate: null, onAfterPrint: null, onBeforePrint: null, onBegin: null, onCancel: null, onCanPlay: null, onCanPlayThrough: null, onChange: null, onClick: null, onClose: null, onCopy: null, onCueChange: null, onCut: null, onDblClick: null, onDrag: null, onDragEnd: null, onDragEnter: null, onDragExit: null, onDragLeave: null, onDragOver: null, onDragStart: null, onDrop: null, onDurationChange: null, onEmptied: null, onEnd: null, onEnded: null, onError: null, onFocus: null, onFocusIn: null, onFocusOut: null, onHashChange: null, onInput: null, onInvalid: null, onKeyDown: null, onKeyPress: null, onKeyUp: null, onLoad: null, onLoadedData: null, onLoadedMetadata: null, onLoadStart: null, onMessage: null, onMouseDown: null, onMouseEnter: null, onMouseLeave: null, onMouseMove: null, onMouseOut: null, onMouseOver: null, onMouseUp: null, onMouseWheel: null, onOffline: null, onOnline: null, onPageHide: null, onPageShow: null, onPaste: null, onPause: null, onPlay: null, onPlaying: null, onPopState: null, onProgress: null, onRateChange: null, onRepeat: null, onReset: null, onResize: null, onScroll: null, onSeeked: null, onSeeking: null, onSelect: null, onShow: null, onStalled: null, onStorage: null, onSubmit: null, onSuspend: null, onTimeUpdate: null, onToggle: null, onUnload: null, onVolumeChange: null, onWaiting: null, onZoom: null, opacity: null, operator: null, order: null, orient: null, orientation: null, origin: null, overflow: null, overlay: null, overlinePosition: B, overlineThickness: B, paintOrder: null, panose1: null, path: null, pathLength: B, patternContentUnits: null, patternTransform: null, patternUnits: null, phase: null, ping: V, pitch: null, playbackOrder: null, pointerEvents: null, points: null, pointsAtX: B, pointsAtY: B, pointsAtZ: B, preserveAlpha: null, preserveAspectRatio: null, primitiveUnits: null, propagate: null, property: U, r: null, radius: null, referrerPolicy: null, refX: null, refY: null, rel: U, rev: U, renderingIntent: null, repeatCount: null, repeatDur: null, requiredExtensions: U, requiredFeatures: U, requiredFonts: U, requiredFormats: U, resource: null, restart: null, result: null, rotate: null, rx: null, ry: null, scale: null, seed: null, shapeRendering: null, side: null, slope: null, snapshotTime: null, specularConstant: B, specularExponent: B, spreadMethod: null, spacing: null, startOffset: null, stdDeviation: null, stemh: null, stemv: null, stitchTiles: null, stopColor: null, stopOpacity: null, strikethroughPosition: B, strikethroughThickness: B, string: null, stroke: null, strokeDashArray: U, strokeDashOffset: null, strokeLineCap: null, strokeLineJoin: null, strokeMiterLimit: B, strokeOpacity: B, strokeWidth: null, style: null, surfaceScale: B, syncBehavior: null, syncBehaviorDefault: null, syncMaster: null, syncTolerance: null, syncToleranceDefault: null, systemLanguage: U, tabIndex: B, tableValues: null, target: null, targetX: B, targetY: B, textAnchor: null, textDecoration: null, textRendering: null, textLength: null, timelineBegin: null, title: null, transformBehavior: null, type: null, typeOf: U, to: null, transform: null, transformOrigin: null, u1: null, u2: null, underlinePosition: B, underlineThickness: B, unicode: null, unicodeBidi: null, unicodeRange: null, unitsPerEm: B, values: null, vAlphabetic: B, vMathematical: B, vectorEffect: null, vHanging: B, vIdeographic: B, version: null, vertAdvY: B, vertOriginX: B, vertOriginY: B, viewBox: null, viewTarget: null, visibility: null, width: null, widths: null, wordSpacing: null, writingMode: null, x: null, x1: null, x2: null, xChannelSelector: null, xHeight: B, y: null, y1: null, y2: null, yChannelSelector: null, z: null, zoomAndPan: null }, space: `svg`, transform: an }), ln = G({ properties: { xLinkActuate: null, xLinkArcRole: null, xLinkHref: null, xLinkRole: null, xLinkShow: null, xLinkTitle: null, xLinkType: null }, space: `xlink`, transform(e12, t2) {
  return `xlink:` + t2.slice(5).toLowerCase();
} }), un = G({ attributes: { xmlnsxlink: `xmlns:xlink` }, properties: { xmlnsXLink: null, xmlns: null }, space: `xmlns`, transform: on }), dn = G({ properties: { xmlBase: null, xmlLang: null, xmlSpace: null }, space: `xml`, transform(e12, t2) {
  return `xml:` + t2.slice(3).toLowerCase();
} }), fn = /[A-Z]/g, pn = /-[a-z]/g, mn = /^data[-\w.:]+$/i;
function hn(e12, t2) {
  let n2 = Xt(t2), r2 = t2, i2 = L;
  if (n2 in e12.normal) return e12.property[e12.normal[n2]];
  if (n2.length > 4 && n2.slice(0, 4) === `data` && mn.test(t2)) {
    if (t2.charAt(4) === `-`) {
      let e13 = t2.slice(5).replace(pn, _n);
      r2 = `data` + e13.charAt(0).toUpperCase() + e13.slice(1);
    } else {
      let e13 = t2.slice(4);
      if (!pn.test(e13)) {
        let n3 = e13.replace(fn, gn);
        n3.charAt(0) !== `-` && (n3 = `-` + n3), t2 = `data` + n3;
      }
    }
    i2 = tn;
  }
  return new i2(r2, t2);
}
function gn(e12) {
  return `-` + e12.toLowerCase();
}
function _n(e12) {
  return e12.charAt(1).toUpperCase();
}
var vn = Yt([rn, sn, ln, un, dn], `html`), yn = Yt([rn, cn, ln, un, dn], `svg`), bn = {}.hasOwnProperty;
function xn(e12, t2) {
  let n2 = t2 || {};
  function r2(t3, ...n3) {
    let i2 = r2.invalid, a2 = r2.handlers;
    if (t3 && bn.call(t3, e12)) {
      let n4 = String(t3[e12]);
      i2 = bn.call(a2, n4) ? a2[n4] : r2.unknown;
    }
    if (i2) return i2.call(this, t3, ...n3);
  }
  return r2.handlers = n2.handlers || {}, r2.invalid = n2.invalid, r2.unknown = n2.unknown, r2;
}
var Sn = /["&'<>`]/g, Cn = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, wn = /[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g, Tn = /[|\\{}()[\]^$+*?.]/g, En = /* @__PURE__ */ new WeakMap();
function Dn(e12, t2) {
  if (e12 = e12.replace(t2.subset ? On(t2.subset) : Sn, r2), t2.subset || t2.escapeOnly) return e12;
  return e12.replace(Cn, n2).replace(wn, r2);
  function n2(e13, n3, r3) {
    return t2.format((e13.charCodeAt(0) - 55296) * 1024 + e13.charCodeAt(1) - 56320 + 65536, r3.charCodeAt(n3 + 2), t2);
  }
  function r2(e13, n3, r3) {
    return t2.format(e13.charCodeAt(0), r3.charCodeAt(n3 + 1), t2);
  }
}
function On(e12) {
  let t2 = En.get(e12);
  return t2 || (t2 = kn(e12), En.set(e12, t2)), t2;
}
function kn(e12) {
  let t2 = [], n2 = -1;
  for (; ++n2 < e12.length; ) t2.push(e12[n2].replace(Tn, `\\$&`));
  return RegExp(`(?:` + t2.join(`|`) + `)`, `g`);
}
var An = /[\dA-Fa-f]/;
function jn(e12, t2, n2) {
  let r2 = `&#x` + e12.toString(16).toUpperCase();
  return n2 && t2 && !An.test(String.fromCharCode(t2)) ? r2 : r2 + `;`;
}
var Mn = /\d/;
function Nn(e12, t2, n2) {
  let r2 = `&#` + String(e12);
  return n2 && t2 && !Mn.test(String.fromCharCode(t2)) ? r2 : r2 + `;`;
}
var Pn = `AElig.AMP.Aacute.Acirc.Agrave.Aring.Atilde.Auml.COPY.Ccedil.ETH.Eacute.Ecirc.Egrave.Euml.GT.Iacute.Icirc.Igrave.Iuml.LT.Ntilde.Oacute.Ocirc.Ograve.Oslash.Otilde.Ouml.QUOT.REG.THORN.Uacute.Ucirc.Ugrave.Uuml.Yacute.aacute.acirc.acute.aelig.agrave.amp.aring.atilde.auml.brvbar.ccedil.cedil.cent.copy.curren.deg.divide.eacute.ecirc.egrave.eth.euml.frac12.frac14.frac34.gt.iacute.icirc.iexcl.igrave.iquest.iuml.laquo.lt.macr.micro.middot.nbsp.not.ntilde.oacute.ocirc.ograve.ordf.ordm.oslash.otilde.ouml.para.plusmn.pound.quot.raquo.reg.sect.shy.sup1.sup2.sup3.szlig.thorn.times.uacute.ucirc.ugrave.uml.uuml.yacute.yen.yuml`.split(`.`), Fn = { nbsp: `\xA0`, iexcl: `\xA1`, cent: `\xA2`, pound: `\xA3`, curren: `\xA4`, yen: `\xA5`, brvbar: `\xA6`, sect: `\xA7`, uml: `\xA8`, copy: `\xA9`, ordf: `\xAA`, laquo: `\xAB`, not: `\xAC`, shy: `\xAD`, reg: `\xAE`, macr: `\xAF`, deg: `\xB0`, plusmn: `\xB1`, sup2: `\xB2`, sup3: `\xB3`, acute: `\xB4`, micro: `\xB5`, para: `\xB6`, middot: `\xB7`, cedil: `\xB8`, sup1: `\xB9`, ordm: `\xBA`, raquo: `\xBB`, frac14: `\xBC`, frac12: `\xBD`, frac34: `\xBE`, iquest: `\xBF`, Agrave: `\xC0`, Aacute: `\xC1`, Acirc: `\xC2`, Atilde: `\xC3`, Auml: `\xC4`, Aring: `\xC5`, AElig: `\xC6`, Ccedil: `\xC7`, Egrave: `\xC8`, Eacute: `\xC9`, Ecirc: `\xCA`, Euml: `\xCB`, Igrave: `\xCC`, Iacute: `\xCD`, Icirc: `\xCE`, Iuml: `\xCF`, ETH: `\xD0`, Ntilde: `\xD1`, Ograve: `\xD2`, Oacute: `\xD3`, Ocirc: `\xD4`, Otilde: `\xD5`, Ouml: `\xD6`, times: `\xD7`, Oslash: `\xD8`, Ugrave: `\xD9`, Uacute: `\xDA`, Ucirc: `\xDB`, Uuml: `\xDC`, Yacute: `\xDD`, THORN: `\xDE`, szlig: `\xDF`, agrave: `\xE0`, aacute: `\xE1`, acirc: `\xE2`, atilde: `\xE3`, auml: `\xE4`, aring: `\xE5`, aelig: `\xE6`, ccedil: `\xE7`, egrave: `\xE8`, eacute: `\xE9`, ecirc: `\xEA`, euml: `\xEB`, igrave: `\xEC`, iacute: `\xED`, icirc: `\xEE`, iuml: `\xEF`, eth: `\xF0`, ntilde: `\xF1`, ograve: `\xF2`, oacute: `\xF3`, ocirc: `\xF4`, otilde: `\xF5`, ouml: `\xF6`, divide: `\xF7`, oslash: `\xF8`, ugrave: `\xF9`, uacute: `\xFA`, ucirc: `\xFB`, uuml: `\xFC`, yacute: `\xFD`, thorn: `\xFE`, yuml: `\xFF`, fnof: `\u0192`, Alpha: `\u0391`, Beta: `\u0392`, Gamma: `\u0393`, Delta: `\u0394`, Epsilon: `\u0395`, Zeta: `\u0396`, Eta: `\u0397`, Theta: `\u0398`, Iota: `\u0399`, Kappa: `\u039A`, Lambda: `\u039B`, Mu: `\u039C`, Nu: `\u039D`, Xi: `\u039E`, Omicron: `\u039F`, Pi: `\u03A0`, Rho: `\u03A1`, Sigma: `\u03A3`, Tau: `\u03A4`, Upsilon: `\u03A5`, Phi: `\u03A6`, Chi: `\u03A7`, Psi: `\u03A8`, Omega: `\u03A9`, alpha: `\u03B1`, beta: `\u03B2`, gamma: `\u03B3`, delta: `\u03B4`, epsilon: `\u03B5`, zeta: `\u03B6`, eta: `\u03B7`, theta: `\u03B8`, iota: `\u03B9`, kappa: `\u03BA`, lambda: `\u03BB`, mu: `\u03BC`, nu: `\u03BD`, xi: `\u03BE`, omicron: `\u03BF`, pi: `\u03C0`, rho: `\u03C1`, sigmaf: `\u03C2`, sigma: `\u03C3`, tau: `\u03C4`, upsilon: `\u03C5`, phi: `\u03C6`, chi: `\u03C7`, psi: `\u03C8`, omega: `\u03C9`, thetasym: `\u03D1`, upsih: `\u03D2`, piv: `\u03D6`, bull: `\u2022`, hellip: `\u2026`, prime: `\u2032`, Prime: `\u2033`, oline: `\u203E`, frasl: `\u2044`, weierp: `\u2118`, image: `\u2111`, real: `\u211C`, trade: `\u2122`, alefsym: `\u2135`, larr: `\u2190`, uarr: `\u2191`, rarr: `\u2192`, darr: `\u2193`, harr: `\u2194`, crarr: `\u21B5`, lArr: `\u21D0`, uArr: `\u21D1`, rArr: `\u21D2`, dArr: `\u21D3`, hArr: `\u21D4`, forall: `\u2200`, part: `\u2202`, exist: `\u2203`, empty: `\u2205`, nabla: `\u2207`, isin: `\u2208`, notin: `\u2209`, ni: `\u220B`, prod: `\u220F`, sum: `\u2211`, minus: `\u2212`, lowast: `\u2217`, radic: `\u221A`, prop: `\u221D`, infin: `\u221E`, ang: `\u2220`, and: `\u2227`, or: `\u2228`, cap: `\u2229`, cup: `\u222A`, int: `\u222B`, there4: `\u2234`, sim: `\u223C`, cong: `\u2245`, asymp: `\u2248`, ne: `\u2260`, equiv: `\u2261`, le: `\u2264`, ge: `\u2265`, sub: `\u2282`, sup: `\u2283`, nsub: `\u2284`, sube: `\u2286`, supe: `\u2287`, oplus: `\u2295`, otimes: `\u2297`, perp: `\u22A5`, sdot: `\u22C5`, lceil: `\u2308`, rceil: `\u2309`, lfloor: `\u230A`, rfloor: `\u230B`, lang: `\u2329`, rang: `\u232A`, loz: `\u25CA`, spades: `\u2660`, clubs: `\u2663`, hearts: `\u2665`, diams: `\u2666`, quot: `"`, amp: `&`, lt: `<`, gt: `>`, OElig: `\u0152`, oelig: `\u0153`, Scaron: `\u0160`, scaron: `\u0161`, Yuml: `\u0178`, circ: `\u02C6`, tilde: `\u02DC`, ensp: `\u2002`, emsp: `\u2003`, thinsp: `\u2009`, zwnj: `\u200C`, zwj: `\u200D`, lrm: `\u200E`, rlm: `\u200F`, ndash: `\u2013`, mdash: `\u2014`, lsquo: `\u2018`, rsquo: `\u2019`, sbquo: `\u201A`, ldquo: `\u201C`, rdquo: `\u201D`, bdquo: `\u201E`, dagger: `\u2020`, Dagger: `\u2021`, permil: `\u2030`, lsaquo: `\u2039`, rsaquo: `\u203A`, euro: `\u20AC` }, In = [`cent`, `copy`, `divide`, `gt`, `lt`, `not`, `para`, `times`], Ln = {}.hasOwnProperty, Rn = {}, K;
for (K in Fn) Ln.call(Fn, K) && (Rn[Fn[K]] = K);
var zn = /[^\dA-Za-z]/;
function Bn(e12, t2, n2, r2) {
  let i2 = String.fromCharCode(e12);
  if (Ln.call(Rn, i2)) {
    let e13 = Rn[i2], a2 = `&` + e13;
    return n2 && Pn.includes(e13) && !In.includes(e13) && (!r2 || t2 && t2 !== 61 && zn.test(String.fromCharCode(t2))) ? a2 : a2 + `;`;
  }
  return ``;
}
function Vn(e12, t2, n2) {
  let r2 = jn(e12, t2, n2.omitOptionalSemicolons), i2;
  if ((n2.useNamedReferences || n2.useShortestReferences) && (i2 = Bn(e12, t2, n2.omitOptionalSemicolons, n2.attribute)), (n2.useShortestReferences || !i2) && n2.useShortestReferences) {
    let i3 = Nn(e12, t2, n2.omitOptionalSemicolons);
    i3.length < r2.length && (r2 = i3);
  }
  return i2 && (!n2.useShortestReferences || i2.length < r2.length) ? i2 : r2;
}
function q(e12, t2) {
  return Dn(e12, Object.assign({ format: Vn }, t2));
}
var Hn = /^>|^->|<!--|-->|--!>|<!-$/g, Un = [`>`], Wn = [`<`, `>`];
function Gn(e12, t2, n2, r2) {
  return r2.settings.bogusComments ? `<?` + q(e12.value, Object.assign({}, r2.settings.characterReferences, { subset: Un })) + `>` : `<!--` + e12.value.replace(Hn, i2) + `-->`;
  function i2(e13) {
    return q(e13, Object.assign({}, r2.settings.characterReferences, { subset: Wn }));
  }
}
function Kn(e12, t2, n2, r2) {
  return `<!` + (r2.settings.upperDoctype ? `DOCTYPE` : `doctype`) + (r2.settings.tightDoctype ? `` : ` `) + `html>`;
}
function qn(e12, t2) {
  let n2 = String(e12);
  if (typeof t2 != `string`) throw TypeError(`Expected character`);
  let r2 = 0, i2 = n2.indexOf(t2);
  for (; i2 !== -1; ) r2++, i2 = n2.indexOf(t2, i2 + t2.length);
  return r2;
}
function Jn(e12, t2) {
  let n2 = t2 || {};
  return (e12[e12.length - 1] === `` ? [...e12, ``] : e12).join((n2.padRight ? ` ` : ``) + `,` + (n2.padLeft === false ? `` : ` `)).trim();
}
function Yn(e12) {
  return e12.join(` `).trim();
}
var Xn = /[ \t\n\f\r]/g;
function Zn(e12) {
  return typeof e12 == `object` ? e12.type === `text` ? Qn(e12.value) : false : Qn(e12);
}
function Qn(e12) {
  return e12.replace(Xn, ``) === ``;
}
var J = tr(1), $n = tr(-1), er = [];
function tr(e12) {
  return t2;
  function t2(t3, n2, r2) {
    let i2 = t3 ? t3.children : er, a2 = (n2 || 0) + e12, o2 = i2[a2];
    if (!r2) for (; o2 && Zn(o2); ) a2 += e12, o2 = i2[a2];
    return o2;
  }
}
var nr = {}.hasOwnProperty;
function rr(e12) {
  return t2;
  function t2(t3, n2, r2) {
    return nr.call(e12, t3.tagName) && e12[t3.tagName](t3, n2, r2);
  }
}
var ir = rr({ body: sr, caption: ar, colgroup: ar, dd: dr, dt: ur, head: ar, html: or, li: lr, optgroup: pr, option: mr, p: cr, rp: fr, rt: fr, tbody: gr, td: yr, tfoot: _r, th: yr, thead: hr, tr: vr });
function ar(e12, t2, n2) {
  let r2 = J(n2, t2, true);
  return !r2 || r2.type !== `comment` && !(r2.type === `text` && Zn(r2.value.charAt(0)));
}
function or(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !r2 || r2.type !== `comment`;
}
function sr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !r2 || r2.type !== `comment`;
}
function cr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return r2 ? r2.type === `element` && (r2.tagName === `address` || r2.tagName === `article` || r2.tagName === `aside` || r2.tagName === `blockquote` || r2.tagName === `details` || r2.tagName === `div` || r2.tagName === `dl` || r2.tagName === `fieldset` || r2.tagName === `figcaption` || r2.tagName === `figure` || r2.tagName === `footer` || r2.tagName === `form` || r2.tagName === `h1` || r2.tagName === `h2` || r2.tagName === `h3` || r2.tagName === `h4` || r2.tagName === `h5` || r2.tagName === `h6` || r2.tagName === `header` || r2.tagName === `hgroup` || r2.tagName === `hr` || r2.tagName === `main` || r2.tagName === `menu` || r2.tagName === `nav` || r2.tagName === `ol` || r2.tagName === `p` || r2.tagName === `pre` || r2.tagName === `section` || r2.tagName === `table` || r2.tagName === `ul`) : !n2 || !(n2.type === `element` && (n2.tagName === `a` || n2.tagName === `audio` || n2.tagName === `del` || n2.tagName === `ins` || n2.tagName === `map` || n2.tagName === `noscript` || n2.tagName === `video`));
}
function lr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !r2 || r2.type === `element` && r2.tagName === `li`;
}
function ur(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !!(r2 && r2.type === `element` && (r2.tagName === `dt` || r2.tagName === `dd`));
}
function dr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !r2 || r2.type === `element` && (r2.tagName === `dt` || r2.tagName === `dd`);
}
function fr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !r2 || r2.type === `element` && (r2.tagName === `rp` || r2.tagName === `rt`);
}
function pr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !r2 || r2.type === `element` && r2.tagName === `optgroup`;
}
function mr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !r2 || r2.type === `element` && (r2.tagName === `option` || r2.tagName === `optgroup`);
}
function hr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !!(r2 && r2.type === `element` && (r2.tagName === `tbody` || r2.tagName === `tfoot`));
}
function gr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !r2 || r2.type === `element` && (r2.tagName === `tbody` || r2.tagName === `tfoot`);
}
function _r(e12, t2, n2) {
  return !J(n2, t2);
}
function vr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !r2 || r2.type === `element` && r2.tagName === `tr`;
}
function yr(e12, t2, n2) {
  let r2 = J(n2, t2);
  return !r2 || r2.type === `element` && (r2.tagName === `td` || r2.tagName === `th`);
}
var br = rr({ body: Cr, colgroup: wr, head: Sr, html: xr, tbody: Tr });
function xr(e12) {
  let t2 = J(e12, -1);
  return !t2 || t2.type !== `comment`;
}
function Sr(e12) {
  let t2 = /* @__PURE__ */ new Set();
  for (let n3 of e12.children) if (n3.type === `element` && (n3.tagName === `base` || n3.tagName === `title`)) {
    if (t2.has(n3.tagName)) return false;
    t2.add(n3.tagName);
  }
  let n2 = e12.children[0];
  return !n2 || n2.type === `element`;
}
function Cr(e12) {
  let t2 = J(e12, -1, true);
  return !t2 || t2.type !== `comment` && !(t2.type === `text` && Zn(t2.value.charAt(0))) && !(t2.type === `element` && (t2.tagName === `meta` || t2.tagName === `link` || t2.tagName === `script` || t2.tagName === `style` || t2.tagName === `template`));
}
function wr(e12, t2, n2) {
  let r2 = $n(n2, t2), i2 = J(e12, -1, true);
  return n2 && r2 && r2.type === `element` && r2.tagName === `colgroup` && ir(r2, n2.children.indexOf(r2), n2) ? false : !!(i2 && i2.type === `element` && i2.tagName === `col`);
}
function Tr(e12, t2, n2) {
  let r2 = $n(n2, t2), i2 = J(e12, -1);
  return n2 && r2 && r2.type === `element` && (r2.tagName === `thead` || r2.tagName === `tbody`) && ir(r2, n2.children.indexOf(r2), n2) ? false : !!(i2 && i2.type === `element` && i2.tagName === `tr`);
}
var Er = { name: [[`	
\f\r &/=>`.split(``), `	
\f\r "&'/=>\``.split(``)], [`\0	
\f\r "&'/<=>`.split(``), `\0	
\f\r "&'/<=>\``.split(``)]], unquoted: [[`	
\f\r &>`.split(``), `\0	
\f\r "&'<=>\``.split(``)], [`\0	
\f\r "&'<=>\``.split(``), `\0	
\f\r "&'<=>\``.split(``)]], single: [[`&'`.split(``), `"&'\``.split(``)], [`\0&'`.split(``), `\0"&'\``.split(``)]], double: [[`"&`.split(``), `"&'\``.split(``)], [`\0"&`.split(``), `\0"&'\``.split(``)]] };
function Dr(e12, t2, n2, r2) {
  let i2 = r2.schema, a2 = i2.space === `svg` ? false : r2.settings.omitOptionalTags, o2 = i2.space === `svg` ? r2.settings.closeEmptyElements : r2.settings.voids.includes(e12.tagName.toLowerCase()), s2 = [], c2;
  i2.space === `html` && e12.tagName === `svg` && (r2.schema = yn);
  let l2 = Or(r2, e12.properties), u2 = r2.all(i2.space === `html` && e12.tagName === `template` ? e12.content : e12);
  return r2.schema = i2, u2 && (o2 = false), (l2 || !a2 || !br(e12, t2, n2)) && (s2.push(`<`, e12.tagName, l2 ? ` ` + l2 : ``), o2 && (i2.space === `svg` || r2.settings.closeSelfClosing) && (c2 = l2.charAt(l2.length - 1), (!r2.settings.tightSelfClosing || c2 === `/` || c2 && c2 !== `"` && c2 !== `'`) && s2.push(` `), s2.push(`/`)), s2.push(`>`)), s2.push(u2), !o2 && (!a2 || !ir(e12, t2, n2)) && s2.push(`</` + e12.tagName + `>`), s2.join(``);
}
function Or(e12, t2) {
  let n2 = [], r2 = -1, i2;
  if (t2) {
    for (i2 in t2) if (t2[i2] !== null && t2[i2] !== void 0) {
      let r3 = kr(e12, i2, t2[i2]);
      r3 && n2.push(r3);
    }
  }
  for (; ++r2 < n2.length; ) {
    let t3 = e12.settings.tightAttributes ? n2[r2].charAt(n2[r2].length - 1) : void 0;
    r2 !== n2.length - 1 && t3 !== `"` && t3 !== `'` && (n2[r2] += ` `);
  }
  return n2.join(``);
}
function kr(e12, t2, n2) {
  let r2 = hn(e12.schema, t2), i2 = e12.settings.allowParseErrors && e12.schema.space === `html` ? 0 : 1, a2 = +!e12.settings.allowDangerousCharacters, o2 = e12.quote, s2;
  if (r2.overloadedBoolean && (n2 === r2.attribute || n2 === ``) ? n2 = true : (r2.boolean || r2.overloadedBoolean) && (typeof n2 != `string` || n2 === r2.attribute || n2 === ``) && (n2 = !!n2), n2 == null || n2 === false || typeof n2 == `number` && Number.isNaN(n2)) return ``;
  let c2 = q(r2.attribute, Object.assign({}, e12.settings.characterReferences, { subset: Er.name[i2][a2] }));
  return n2 === true || (n2 = Array.isArray(n2) ? (r2.commaSeparated ? Jn : Yn)(n2, { padLeft: !e12.settings.tightCommaSeparatedLists }) : String(n2), e12.settings.collapseEmptyAttributes && !n2) ? c2 : (e12.settings.preferUnquoted && (s2 = q(n2, Object.assign({}, e12.settings.characterReferences, { attribute: true, subset: Er.unquoted[i2][a2] }))), s2 !== n2 && (e12.settings.quoteSmart && qn(n2, o2) > qn(n2, e12.alternative) && (o2 = e12.alternative), s2 = o2 + q(n2, Object.assign({}, e12.settings.characterReferences, { subset: (o2 === `'` ? Er.single : Er.double)[i2][a2], attribute: true })) + o2), c2 + (s2 && `=` + s2));
}
var Ar = [`<`, `&`];
function jr(e12, t2, n2, r2) {
  return n2 && n2.type === `element` && (n2.tagName === `script` || n2.tagName === `style`) ? e12.value : q(e12.value, Object.assign({}, r2.settings.characterReferences, { subset: Ar }));
}
function Mr(e12, t2, n2, r2) {
  return r2.settings.allowDangerousHtml ? e12.value : jr(e12, t2, n2, r2);
}
function Nr(e12, t2, n2, r2) {
  return r2.all(e12);
}
var Pr = xn(`type`, { invalid: Fr, unknown: Ir, handlers: { comment: Gn, doctype: Kn, element: Dr, raw: Mr, root: Nr, text: jr } });
function Fr(e12) {
  throw Error("Expected node, not `" + e12 + "`");
}
function Ir(e12) {
  throw Error("Cannot compile unknown node `" + e12.type + "`");
}
var Lr = {}, Rr = {}, zr = [];
function Br(e12, t2) {
  let n2 = t2 || Lr, r2 = n2.quote || `"`, i2 = r2 === `"` ? `'` : `"`;
  if (r2 !== `"` && r2 !== `'`) throw Error("Invalid quote `" + r2 + "`, expected `'` or `\"`");
  return { one: Vr, all: Hr, settings: { omitOptionalTags: n2.omitOptionalTags || false, allowParseErrors: n2.allowParseErrors || false, allowDangerousCharacters: n2.allowDangerousCharacters || false, quoteSmart: n2.quoteSmart || false, preferUnquoted: n2.preferUnquoted || false, tightAttributes: n2.tightAttributes || false, upperDoctype: n2.upperDoctype || false, tightDoctype: n2.tightDoctype || false, bogusComments: n2.bogusComments || false, tightCommaSeparatedLists: n2.tightCommaSeparatedLists || false, tightSelfClosing: n2.tightSelfClosing || false, collapseEmptyAttributes: n2.collapseEmptyAttributes || false, allowDangerousHtml: n2.allowDangerousHtml || false, voids: n2.voids || Jt, characterReferences: n2.characterReferences || Rr, closeSelfClosing: n2.closeSelfClosing || false, closeEmptyElements: n2.closeEmptyElements || false }, schema: n2.space === `svg` ? yn : vn, quote: r2, alternative: i2 }.one(Array.isArray(e12) ? { type: `root`, children: e12 } : e12, void 0, void 0);
}
function Vr(e12, t2, n2) {
  return Pr(e12, t2, n2, this);
}
function Hr(e12) {
  let t2 = [], n2 = e12 && e12.children || zr, r2 = -1;
  for (; ++r2 < n2.length; ) t2[r2] = this.one(n2[r2], r2, e12);
  return t2.join(``);
}
var Ur = /\s+/g;
function Wr(e12, t2) {
  var _a2;
  if (!t2) return e12;
  e12.properties || (e12.properties = {}), (_a2 = e12.properties).class || (_a2.class = []), typeof e12.properties.class == `string` && (e12.properties.class = e12.properties.class.split(Ur)), Array.isArray(e12.properties.class) || (e12.properties.class = []);
  let n2 = Array.isArray(t2) ? t2 : t2.split(Ur);
  for (let t3 of n2) t3 && !e12.properties.class.includes(t3) && e12.properties.class.push(t3);
  return e12;
}
function Gr(e12) {
  let t2 = yt(e12, true).map(([e13]) => e13);
  function n2(n3) {
    if (n3 === e12.length) return { line: t2.length - 1, character: t2.at(-1).length };
    let r3 = n3, i2 = 0;
    for (let e13 of t2) {
      if (r3 < e13.length) break;
      r3 -= e13.length, i2++;
    }
    return { line: i2, character: r3 };
  }
  function r2(e13, n3) {
    let r3 = 0;
    for (let n4 = 0; n4 < e13; n4++) r3 += t2[n4].length;
    return r3 += n3, r3;
  }
  return { lines: t2, indexToPos: n2, posToIndex: r2 };
}
var Kr = [`color`, `background-color`];
function qr(e12, t2) {
  let n2 = 0, r2 = [];
  for (let i2 of t2) i2 > n2 && r2.push({ ...e12, content: e12.content.slice(n2, i2), offset: e12.offset + n2 }), n2 = i2;
  return n2 < e12.content.length && r2.push({ ...e12, content: e12.content.slice(n2), offset: e12.offset + n2 }), r2;
}
function Jr(e12, t2) {
  let n2 = [...t2 instanceof Set ? t2 : new Set(t2)].sort((e13, t3) => e13 - t3);
  return n2.length ? e12.map((e13) => e13.flatMap((e14) => {
    let t3 = n2.filter((t4) => e14.offset < t4 && t4 < e14.offset + e14.content.length).map((t4) => t4 - e14.offset).sort((e15, t4) => e15 - t4);
    return t3.length ? qr(e14, t3) : e14;
  })) : e12;
}
function Yr(e12, t2, n2, r2, i2 = `css-vars`) {
  let o2 = { content: e12.content, explanation: e12.explanation, offset: e12.offset }, s2 = t2.map((t3) => Xr(e12.variants[t3])), c2 = new Set(s2.flatMap((e13) => Object.keys(e13))), l2 = {}, u2 = (e13, r3) => {
    let i3 = r3 === `color` ? `` : r3 === `background-color` ? `-bg` : `-${r3}`;
    return n2 + t2[e13] + (r3 === `color` ? `` : i3);
  };
  return s2.forEach((e13, n3) => {
    for (let o3 of c2) {
      let c3 = e13[o3] || `inherit`;
      if (n3 === 0 && r2 && Kr.includes(o3)) if (r2 === `light-dark()` && s2.length > 1) {
        let e14 = t2.findIndex((e15) => e15 === `light`), r3 = t2.findIndex((e15) => e15 === `dark`);
        if (e14 === -1 || r3 === -1) throw new a('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');
        l2[o3] = `light-dark(${s2[e14][o3] || `inherit`}, ${s2[r3][o3] || `inherit`})`, i2 === `css-vars` && (l2[u2(n3, o3)] = c3);
      } else l2[o3] = c3;
      else i2 === `css-vars` && (l2[u2(n3, o3)] = c3);
    }
  }), o2.htmlStyle = l2, o2;
}
function Xr(e12) {
  let t2 = {};
  if (e12.color && (t2.color = e12.color), e12.bgColor && (t2[`background-color`] = e12.bgColor), e12.fontStyle) {
    e12.fontStyle & b.Italic && (t2[`font-style`] = `italic`), e12.fontStyle & b.Bold && (t2[`font-weight`] = `bold`);
    let n2 = [];
    e12.fontStyle & b.Underline && n2.push(`underline`), e12.fontStyle & b.Strikethrough && n2.push(`line-through`), n2.length && (t2[`text-decoration`] = n2.join(` `));
  }
  return t2;
}
function Zr(e12) {
  return typeof e12 == `string` ? e12 : Object.entries(e12).map(([e13, t2]) => `${e13}:${t2}`).join(`;`);
}
function Qr() {
  let e12 = /* @__PURE__ */ new WeakMap();
  function t2(t3) {
    if (!e12.has(t3.meta)) {
      let r2 = function(e13) {
        if (typeof e13 == `number`) {
          if (e13 < 0 || e13 > t3.source.length) throw new a(`Invalid decoration offset: ${e13}. Code length: ${t3.source.length}`);
          return { ...n2.indexToPos(e13), offset: e13 };
        } else {
          let t4 = n2.lines[e13.line];
          if (t4 === void 0) throw new a(`Invalid decoration position ${JSON.stringify(e13)}. Lines length: ${n2.lines.length}`);
          let r3 = e13.character;
          if (r3 < 0 && (r3 = t4.length + r3), r3 < 0 || r3 > t4.length) throw new a(`Invalid decoration position ${JSON.stringify(e13)}. Line ${e13.line} length: ${t4.length}`);
          return { ...e13, character: r3, offset: n2.posToIndex(e13.line, r3) };
        }
      };
      let n2 = Gr(t3.source);
      let i2 = (t3.options.decorations || []).map((e13) => ({ ...e13, start: r2(e13.start), end: r2(e13.end) }));
      $r(i2), e12.set(t3.meta, { decorations: i2, converter: n2, source: t3.source });
    }
    return e12.get(t3.meta);
  }
  return { name: `shiki:decorations`, tokens(e13) {
    if (this.options.decorations?.length) return Jr(e13, t2(this).decorations.flatMap((e14) => [e14.start.offset, e14.end.offset]));
  }, code(e13) {
    if (!this.options.decorations?.length) return;
    let n2 = t2(this), r2 = [...e13.children].filter((e14) => e14.type === `element` && e14.tagName === `span`);
    if (r2.length !== n2.converter.lines.length) throw new a(`Number of lines in code element (${r2.length}) does not match the number of lines in the source (${n2.converter.lines.length}). Failed to apply decorations.`);
    function i2(e14, t3, n3, i3) {
      let o3 = r2[e14], c3 = ``, l3 = -1, u2 = -1;
      if (t3 === 0 && (l3 = 0), n3 === 0 && (u2 = 0), n3 === 1 / 0 && (u2 = o3.children.length), l3 === -1 || u2 === -1) for (let e15 = 0; e15 < o3.children.length; e15++) c3 += ei(o3.children[e15]), l3 === -1 && c3.length === t3 && (l3 = e15 + 1), u2 === -1 && c3.length === n3 && (u2 = e15 + 1);
      if (l3 === -1) throw new a(`Failed to find start index for decoration ${JSON.stringify(i3.start)}`);
      if (u2 === -1) throw new a(`Failed to find end index for decoration ${JSON.stringify(i3.end)}`);
      let d2 = o3.children.slice(l3, u2);
      if (!i3.alwaysWrap && d2.length === o3.children.length) s2(o3, i3, `line`);
      else if (!i3.alwaysWrap && d2.length === 1 && d2[0].type === `element`) s2(d2[0], i3, `token`);
      else {
        let e15 = { type: `element`, tagName: `span`, properties: {}, children: d2 };
        s2(e15, i3, `wrapper`), o3.children.splice(l3, d2.length, e15);
      }
    }
    function o2(e14, t3) {
      r2[e14] = s2(r2[e14], t3, `line`);
    }
    function s2(e14, t3, n3) {
      let r3 = t3.properties || {}, i3 = t3.transform || ((e15) => e15);
      return e14.tagName = t3.tagName || `span`, e14.properties = { ...e14.properties, ...r3, class: e14.properties.class }, t3.properties?.class && Wr(e14, t3.properties.class), e14 = i3(e14, n3) || e14, e14;
    }
    let c2 = [], l2 = n2.decorations.sort((e14, t3) => t3.start.offset - e14.start.offset || e14.end.offset - t3.end.offset);
    for (let e14 of l2) {
      let { start: t3, end: n3 } = e14;
      if (t3.line === n3.line) i2(t3.line, t3.character, n3.character, e14);
      else if (t3.line < n3.line) {
        i2(t3.line, t3.character, 1 / 0, e14);
        for (let r3 = t3.line + 1; r3 < n3.line; r3++) c2.unshift(() => o2(r3, e14));
        i2(n3.line, 0, n3.character, e14);
      }
    }
    c2.forEach((e14) => e14());
  } };
}
function $r(e12) {
  for (let t2 = 0; t2 < e12.length; t2++) {
    let n2 = e12[t2];
    if (n2.start.offset > n2.end.offset) throw new a(`Invalid decoration range: ${JSON.stringify(n2.start)} - ${JSON.stringify(n2.end)}`);
    for (let r2 = t2 + 1; r2 < e12.length; r2++) {
      let t3 = e12[r2], i2 = n2.start.offset <= t3.start.offset && t3.start.offset < n2.end.offset, o2 = n2.start.offset < t3.end.offset && t3.end.offset <= n2.end.offset, s2 = t3.start.offset <= n2.start.offset && n2.start.offset < t3.end.offset, c2 = t3.start.offset < n2.end.offset && n2.end.offset <= t3.end.offset;
      if (i2 || o2 || s2 || c2) {
        if (i2 && o2 || s2 && c2 || s2 && n2.start.offset === n2.end.offset || o2 && t3.start.offset === t3.end.offset) continue;
        throw new a(`Decorations ${JSON.stringify(n2.start)} and ${JSON.stringify(t3.start)} intersect.`);
      }
    }
  }
}
function ei(e12) {
  return e12.type === `text` ? e12.value : e12.type === `element` ? e12.children.map(ei).join(``) : ``;
}
var ti = [Qr()];
function ni(e12) {
  let t2 = ri(e12.transformers || []);
  return [...t2.pre, ...t2.normal, ...t2.post, ...ti];
}
function ri(e12) {
  let t2 = [], n2 = [], r2 = [];
  for (let i2 of e12) switch (i2.enforce) {
    case `pre`:
      t2.push(i2);
      break;
    case `post`:
      n2.push(i2);
      break;
    default:
      r2.push(i2);
  }
  return { pre: t2, post: n2, normal: r2 };
}
var Y = [`black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `brightBlack`, `brightRed`, `brightGreen`, `brightYellow`, `brightBlue`, `brightMagenta`, `brightCyan`, `brightWhite`], ii = { 1: `bold`, 2: `dim`, 3: `italic`, 4: `underline`, 7: `reverse`, 8: `hidden`, 9: `strikethrough` };
function ai(e12, t2) {
  let n2 = e12.indexOf(`\x1B`, t2);
  if (n2 !== -1 && e12[n2 + 1] === `[`) {
    let t3 = e12.indexOf(`m`, n2);
    if (t3 !== -1) return { sequence: e12.substring(n2 + 2, t3).split(`;`), startPosition: n2, position: t3 + 1 };
  }
  return { position: e12.length };
}
function oi(e12) {
  let t2 = e12.shift();
  if (t2 === `2`) {
    let t3 = e12.splice(0, 3).map((e13) => Number.parseInt(e13));
    return t3.length !== 3 || t3.some((e13) => Number.isNaN(e13)) ? void 0 : { type: `rgb`, rgb: t3 };
  } else if (t2 === `5`) {
    let t3 = e12.shift();
    if (t3) return { type: `table`, index: Number(t3) };
  }
}
function si(e12) {
  let t2 = [];
  for (; e12.length > 0; ) {
    let n2 = e12.shift();
    if (!n2) continue;
    let r2 = Number.parseInt(n2);
    if (!Number.isNaN(r2)) if (r2 === 0) t2.push({ type: `resetAll` });
    else if (r2 <= 9) ii[r2] && t2.push({ type: `setDecoration`, value: ii[r2] });
    else if (r2 <= 29) {
      let e13 = ii[r2 - 20];
      e13 && (t2.push({ type: `resetDecoration`, value: e13 }), e13 === `dim` && t2.push({ type: `resetDecoration`, value: `bold` }));
    } else if (r2 <= 37) t2.push({ type: `setForegroundColor`, value: { type: `named`, name: Y[r2 - 30] } });
    else if (r2 === 38) {
      let n3 = oi(e12);
      n3 && t2.push({ type: `setForegroundColor`, value: n3 });
    } else if (r2 === 39) t2.push({ type: `resetForegroundColor` });
    else if (r2 <= 47) t2.push({ type: `setBackgroundColor`, value: { type: `named`, name: Y[r2 - 40] } });
    else if (r2 === 48) {
      let n3 = oi(e12);
      n3 && t2.push({ type: `setBackgroundColor`, value: n3 });
    } else r2 === 49 ? t2.push({ type: `resetBackgroundColor` }) : r2 === 53 ? t2.push({ type: `setDecoration`, value: `overline` }) : r2 === 55 ? t2.push({ type: `resetDecoration`, value: `overline` }) : r2 >= 90 && r2 <= 97 ? t2.push({ type: `setForegroundColor`, value: { type: `named`, name: Y[r2 - 90 + 8] } }) : r2 >= 100 && r2 <= 107 && t2.push({ type: `setBackgroundColor`, value: { type: `named`, name: Y[r2 - 100 + 8] } });
  }
  return t2;
}
function ci() {
  let e12 = null, t2 = null, n2 = /* @__PURE__ */ new Set();
  return { parse(r2) {
    let i2 = [], a2 = 0;
    do {
      let o2 = ai(r2, a2), s2 = o2.sequence ? r2.substring(a2, o2.startPosition) : r2.substring(a2);
      if (s2.length > 0 && i2.push({ value: s2, foreground: e12, background: t2, decorations: new Set(n2) }), o2.sequence) {
        let r3 = si(o2.sequence);
        for (let i3 of r3) i3.type === `resetAll` ? (e12 = null, t2 = null, n2.clear()) : i3.type === `resetForegroundColor` ? e12 = null : i3.type === `resetBackgroundColor` ? t2 = null : i3.type === `resetDecoration` && n2.delete(i3.value);
        for (let i3 of r3) i3.type === `setForegroundColor` ? e12 = i3.value : i3.type === `setBackgroundColor` ? t2 = i3.value : i3.type === `setDecoration` && n2.add(i3.value);
      }
      a2 = o2.position;
    } while (a2 < r2.length);
    return i2;
  } };
}
var li = { black: `#000000`, red: `#bb0000`, green: `#00bb00`, yellow: `#bbbb00`, blue: `#0000bb`, magenta: `#ff00ff`, cyan: `#00bbbb`, white: `#eeeeee`, brightBlack: `#555555`, brightRed: `#ff5555`, brightGreen: `#00ff00`, brightYellow: `#ffff55`, brightBlue: `#5555ff`, brightMagenta: `#ff55ff`, brightCyan: `#55ffff`, brightWhite: `#ffffff` };
function ui(e12 = li) {
  function t2(t3) {
    return e12[t3];
  }
  function n2(e13) {
    return `#${e13.map((e14) => Math.max(0, Math.min(e14, 255)).toString(16).padStart(2, `0`)).join(``)}`;
  }
  let r2;
  function i2() {
    if (r2) return r2;
    r2 = [];
    for (let e14 = 0; e14 < Y.length; e14++) r2.push(t2(Y[e14]));
    let e13 = [0, 95, 135, 175, 215, 255];
    for (let t3 = 0; t3 < 6; t3++) for (let i4 = 0; i4 < 6; i4++) for (let a3 = 0; a3 < 6; a3++) r2.push(n2([e13[t3], e13[i4], e13[a3]]));
    let i3 = 8;
    for (let e14 = 0; e14 < 24; e14++, i3 += 10) r2.push(n2([i3, i3, i3]));
    return r2;
  }
  function a2(e13) {
    return i2()[e13];
  }
  function o2(e13) {
    switch (e13.type) {
      case `named`:
        return t2(e13.name);
      case `rgb`:
        return n2(e13.rgb);
      case `table`:
        return a2(e13.index);
    }
  }
  return { value: o2 };
}
var di = /#([0-9a-f]{3,8})/i, fi = /var\((--[\w-]+-ansi-[\w-]+)\)/, pi = { black: `#000000`, red: `#cd3131`, green: `#0DBC79`, yellow: `#E5E510`, blue: `#2472C8`, magenta: `#BC3FBC`, cyan: `#11A8CD`, white: `#E5E5E5`, brightBlack: `#666666`, brightRed: `#F14C4C`, brightGreen: `#23D18B`, brightYellow: `#F5F543`, brightBlue: `#3B8EEA`, brightMagenta: `#D670D6`, brightCyan: `#29B8DB`, brightWhite: `#FFFFFF` };
function mi(e12, t2, n2) {
  let r2 = j(e12, n2), i2 = yt(t2), a2 = ui(Object.fromEntries(Y.map((t3) => {
    let n3 = `terminal.ansi${t3[0].toUpperCase()}${t3.substring(1)}`;
    return [t3, e12.colors?.[n3] || pi[t3]];
  }))), o2 = ci();
  return i2.map((t3) => o2.parse(t3[0]).map((n3) => {
    let i3, o3;
    n3.decorations.has(`reverse`) ? (i3 = n3.background ? a2.value(n3.background) : e12.bg, o3 = n3.foreground ? a2.value(n3.foreground) : e12.fg) : (i3 = n3.foreground ? a2.value(n3.foreground) : e12.fg, o3 = n3.background ? a2.value(n3.background) : void 0), i3 = M(i3, r2), o3 = M(o3, r2), n3.decorations.has(`dim`) && (i3 = hi(i3));
    let s2 = b.None;
    return n3.decorations.has(`bold`) && (s2 |= b.Bold), n3.decorations.has(`italic`) && (s2 |= b.Italic), n3.decorations.has(`underline`) && (s2 |= b.Underline), n3.decorations.has(`strikethrough`) && (s2 |= b.Strikethrough), { content: n3.value, offset: t3[1], color: i3, bgColor: o3, fontStyle: s2 };
  }));
}
function hi(e12) {
  let t2 = e12.match(di);
  if (t2) {
    let e13 = t2[1];
    if (e13.length === 8) {
      let t3 = Math.round(Number.parseInt(e13.slice(6, 8), 16) / 2).toString(16).padStart(2, `0`);
      return `#${e13.slice(0, 6)}${t3}`;
    } else if (e13.length === 6) return `#${e13}80`;
    else if (e13.length === 4) {
      let t3 = e13[0], n3 = e13[1], r2 = e13[2], i2 = e13[3];
      return `#${t3}${t3}${n3}${n3}${r2}${r2}${Math.round(Number.parseInt(`${i2}${i2}`, 16) / 2).toString(16).padStart(2, `0`)}`;
    } else if (e13.length === 3) {
      let t3 = e13[0], n3 = e13[1], r2 = e13[2];
      return `#${t3}${t3}${n3}${n3}${r2}${r2}80`;
    }
  }
  let n2 = e12.match(fi);
  return n2 ? `var(${n2[1]}-dim)` : e12;
}
function gi(e12, t2, n2 = {}) {
  let r2 = e12.resolveLangAlias(n2.lang || `text`), { theme: i2 = e12.getLoadedThemes()[0] } = n2;
  if (!mt(r2) && !gt(i2) && r2 === `ansi`) {
    let { theme: r3 } = e12.setTheme(i2);
    return mi(r3, t2, n2);
  }
  return Lt(e12, t2, n2);
}
function X(e12, t2, n2) {
  let r2, i2, o2, s2, c2, l2;
  if (`themes` in n2) {
    let { defaultColor: u2 = `light`, cssVariablePrefix: d2 = `--shiki-`, colorsRendering: f2 = `css-vars` } = n2, p2 = Object.entries(n2.themes).filter((e13) => e13[1]).map((e13) => ({ color: e13[0], theme: e13[1] })).sort((e13, t3) => e13.color === u2 ? -1 : +(t3.color === u2));
    if (p2.length === 0) throw new a("`themes` option must not be empty");
    let m2 = Kt(e12, t2, n2, gi);
    if (l2 = P(m2), u2 && u2 !== `light-dark()` && !p2.some((e13) => e13.color === u2)) throw new a(`\`themes\` option must contain the defaultColor key \`${u2}\``);
    let h2 = p2.map((t3) => e12.getTheme(t3.theme)), g2 = p2.map((e13) => e13.color);
    o2 = m2.map((e13) => e13.map((e14) => Yr(e14, g2, d2, u2, f2))), l2 && Mt(o2, l2);
    let _2 = p2.map((e13) => j(e13.theme, n2));
    i2 = _i(p2, h2, _2, d2, u2, `fg`, f2), r2 = _i(p2, h2, _2, d2, u2, `bg`, f2), s2 = `shiki-themes ${h2.map((e13) => e13.name).join(` `)}`, c2 = u2 ? void 0 : [i2, r2].join(`;`);
  } else if (`theme` in n2) {
    let a2 = j(n2.theme, n2);
    o2 = gi(e12, t2, n2);
    let c3 = e12.getTheme(n2.theme);
    r2 = M(c3.bg, a2), i2 = M(c3.fg, a2), s2 = c3.name, l2 = P(o2);
  } else throw new a("Invalid options, either `theme` or `themes` must be provided");
  return { tokens: o2, fg: i2, bg: r2, themeName: s2, rootStyle: c2, grammarState: l2 };
}
function _i(e12, t2, n2, r2, i2, o2, s2) {
  return e12.map((c2, l2) => {
    let u2 = M(t2[l2][o2], n2[l2]) || `inherit`, d2 = `${r2 + c2.color}${o2 === `bg` ? `-bg` : ``}:${u2}`;
    if (l2 === 0 && i2) {
      if (i2 === `light-dark()` && e12.length > 1) {
        let r3 = e12.findIndex((e13) => e13.color === `light`), i3 = e12.findIndex((e13) => e13.color === `dark`);
        if (r3 === -1 || i3 === -1) throw new a('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');
        return `light-dark(${M(t2[r3][o2], n2[r3]) || `inherit`}, ${M(t2[i3][o2], n2[i3]) || `inherit`});${d2}`;
      }
      return u2;
    }
    return s2 === `css-vars` ? d2 : null;
  }).filter((e13) => !!e13).join(`;`);
}
var vi = /^\s+$/, yi = /^(\s*)(.*?)(\s*)$/;
function bi(e12, t2, n2, r2 = { meta: {}, options: n2, codeToHast: (t3, n3) => bi(e12, t3, n3), codeToTokens: (t3, n3) => X(e12, t3, n3) }) {
  let i2 = t2;
  for (let e13 of ni(n2)) i2 = e13.preprocess?.call(r2, i2, n2) || i2;
  let { tokens: a2, fg: o2, bg: s2, themeName: c2, rootStyle: l2, grammarState: u2 } = X(e12, i2, n2), { mergeWhitespaces: d2 = true, mergeSameStyleTokens: f2 = false } = n2;
  d2 === true ? a2 = Si(a2) : d2 === `never` && (a2 = Ci(a2)), f2 && (a2 = wi(a2));
  let p2 = { ...r2, get source() {
    return i2;
  } };
  for (let e13 of ni(n2)) a2 = e13.tokens?.call(p2, a2) || a2;
  return xi(a2, { ...n2, fg: o2, bg: s2, themeName: c2, rootStyle: n2.rootStyle === false ? false : n2.rootStyle ?? l2 }, p2, u2);
}
function xi(e12, t2, n2, r2 = P(e12)) {
  let i2 = ni(t2), a2 = [], o2 = { type: `root`, children: [] }, { structure: s2 = `classic`, tabindex: c2 = `0` } = t2, l2 = { class: `shiki ${t2.themeName || ``}` };
  t2.rootStyle !== false && (t2.rootStyle == null ? l2.style = `background-color:${t2.bg};color:${t2.fg}` : l2.style = t2.rootStyle), c2 !== false && c2 != null && (l2.tabindex = c2.toString());
  for (let [e13, n3] of Object.entries(t2.meta || {})) e13.startsWith(`_`) || (l2[e13] = n3);
  let u2 = { type: `element`, tagName: `pre`, properties: l2, children: [], data: t2.data }, d2 = { type: `element`, tagName: `code`, properties: {}, children: a2 }, f2 = [], p2 = { ...n2, structure: s2, addClassToHast: Wr, get source() {
    return n2.source;
  }, get tokens() {
    return e12;
  }, get options() {
    return t2;
  }, get root() {
    return o2;
  }, get pre() {
    return u2;
  }, get code() {
    return d2;
  }, get lines() {
    return f2;
  } };
  if (e12.forEach((e13, t3) => {
    t3 && (s2 === `inline` ? o2.children.push({ type: `element`, tagName: `br`, properties: {}, children: [] }) : s2 === `classic` && a2.push({ type: `text`, value: `
` }));
    let n3 = { type: `element`, tagName: `span`, properties: { class: `line` }, children: [] }, r3 = 0;
    for (let a3 of e13) {
      let e14 = { type: `element`, tagName: `span`, properties: { ...a3.htmlAttrs }, children: [{ type: `text`, value: a3.content }] }, c3 = Zr(a3.htmlStyle || Xr(a3));
      c3 && (e14.properties.style = c3);
      for (let o3 of i2) e14 = o3?.span?.call(p2, e14, t3 + 1, r3, n3, a3) || e14;
      s2 === `inline` ? o2.children.push(e14) : s2 === `classic` && n3.children.push(e14), r3 += a3.content.length;
    }
    if (s2 === `classic`) {
      for (let e14 of i2) n3 = e14?.line?.call(p2, n3, t3 + 1) || n3;
      f2.push(n3), a2.push(n3);
    } else s2 === `inline` && f2.push(n3);
  }), s2 === `classic`) {
    for (let e13 of i2) d2 = e13?.code?.call(p2, d2) || d2;
    u2.children.push(d2);
    for (let e13 of i2) u2 = e13?.pre?.call(p2, u2) || u2;
    o2.children.push(u2);
  } else if (s2 === `inline`) {
    let e13 = [], t3 = { type: `element`, tagName: `span`, properties: { class: `line` }, children: [] };
    for (let n4 of o2.children) n4.type === `element` && n4.tagName === `br` ? (e13.push(t3), t3 = { type: `element`, tagName: `span`, properties: { class: `line` }, children: [] }) : (n4.type === `element` || n4.type === `text`) && t3.children.push(n4);
    e13.push(t3);
    let n3 = { type: `element`, tagName: `code`, properties: {}, children: e13 };
    for (let e14 of i2) n3 = e14?.code?.call(p2, n3) || n3;
    o2.children = [];
    for (let e14 = 0; e14 < n3.children.length; e14++) {
      e14 > 0 && o2.children.push({ type: `element`, tagName: `br`, properties: {}, children: [] });
      let t4 = n3.children[e14];
      t4.type === `element` && o2.children.push(...t4.children);
    }
  }
  let m2 = o2;
  for (let e13 of i2) m2 = e13?.root?.call(p2, m2) || m2;
  return r2 && Mt(m2, r2), m2;
}
function Si(e12) {
  return e12.map((e13) => {
    let t2 = [], n2 = ``, r2;
    return e13.forEach((i2, a2) => {
      let o2 = !(i2.fontStyle && (i2.fontStyle & b.Underline || i2.fontStyle & b.Strikethrough));
      o2 && vi.test(i2.content) && e13[a2 + 1] ? (r2 === void 0 && (r2 = i2.offset), n2 += i2.content) : n2 ? (o2 ? t2.push({ ...i2, offset: r2, content: n2 + i2.content }) : t2.push({ content: n2, offset: r2 }, i2), r2 = void 0, n2 = ``) : t2.push(i2);
    }), t2;
  });
}
function Ci(e12) {
  return e12.map((e13) => e13.flatMap((e14) => {
    if (vi.test(e14.content)) return e14;
    let t2 = e14.content.match(yi);
    if (!t2) return e14;
    let [, n2, r2, i2] = t2;
    if (!n2 && !i2) return e14;
    let a2 = [{ ...e14, offset: e14.offset + n2.length, content: r2 }];
    return n2 && a2.unshift({ content: n2, offset: e14.offset }), i2 && a2.push({ content: i2, offset: e14.offset + n2.length + r2.length }), a2;
  }));
}
function wi(e12) {
  return e12.map((e13) => {
    let t2 = [];
    for (let n2 of e13) {
      if (t2.length === 0) {
        t2.push({ ...n2 });
        continue;
      }
      let e14 = t2.at(-1), r2 = Zr(e14.htmlStyle || Xr(e14)), i2 = Zr(n2.htmlStyle || Xr(n2)), a2 = e14.fontStyle && (e14.fontStyle & b.Underline || e14.fontStyle & b.Strikethrough), o2 = n2.fontStyle && (n2.fontStyle & b.Underline || n2.fontStyle & b.Strikethrough);
      !a2 && !o2 && r2 === i2 ? e14.content += n2.content : t2.push({ ...n2 });
    }
    return t2;
  });
}
var Ti = Br;
function Ei(e12, t2, n2) {
  let r2 = { meta: {}, options: n2, codeToHast: (t3, n3) => bi(e12, t3, n3), codeToTokens: (t3, n3) => X(e12, t3, n3) }, i2 = Ti(bi(e12, t2, n2, r2));
  for (let e13 of ni(n2)) i2 = e13.postprocess?.call(r2, i2, n2) || i2;
  return i2;
}
async function Di(e12) {
  let t2 = await At(e12);
  return { getLastGrammarState: (...e13) => Rt(t2, ...e13), codeToTokensBase: (e13, n2) => gi(t2, e13, n2), codeToTokensWithThemes: (e13, n2) => Kt(t2, e13, n2), codeToTokens: (e13, n2) => X(t2, e13, n2), codeToHast: (e13, n2) => bi(t2, e13, n2), codeToHtml: (e13, n2) => Ei(t2, e13, n2), getBundledLanguages: () => ({}), getBundledThemes: () => ({}), ...t2, getInternalContext: () => t2 };
}
t();
var Oi = class extends Error {
  constructor(e12) {
    super(e12), this.name = `ShikiError`;
  }
};
function ki() {
  return 2147483648;
}
function Ai() {
  return typeof performance < `u` ? performance.now() : Date.now();
}
var ji = (e12, t2) => e12 + (t2 - e12 % t2) % t2;
async function Mi(e12) {
  let t2, n2, r2 = {};
  function i2(e13) {
    n2 = e13, r2.HEAPU8 = new Uint8Array(e13), r2.HEAPU32 = new Uint32Array(e13);
  }
  function a2(e13, t3, n3) {
    r2.HEAPU8.copyWithin(e13, t3, t3 + n3);
  }
  function o2(e13) {
    try {
      return t2.grow(e13 - n2.byteLength + 65535 >>> 16), i2(t2.buffer), 1;
    } catch {
    }
  }
  function s2(e13) {
    let t3 = r2.HEAPU8.length;
    e13 >>>= 0;
    let n3 = ki();
    if (e13 > n3) return false;
    for (let r3 = 1; r3 <= 4; r3 *= 2) {
      let i3 = t3 * (1 + 0.2 / r3);
      if (i3 = Math.min(i3, e13 + 100663296), o2(Math.min(n3, ji(Math.max(e13, i3), 65536)))) return true;
    }
    return false;
  }
  let c2 = typeof TextDecoder < `u` ? new TextDecoder(`utf8`) : void 0;
  function l2(e13, t3, n3 = 1024) {
    let r3 = t3 + n3, i3 = t3;
    for (; e13[i3] && !(i3 >= r3); ) ++i3;
    if (i3 - t3 > 16 && e13.buffer && c2) return c2.decode(e13.subarray(t3, i3));
    let a3 = ``;
    for (; t3 < i3; ) {
      let n4 = e13[t3++];
      if (!(n4 & 128)) {
        a3 += String.fromCharCode(n4);
        continue;
      }
      let r4 = e13[t3++] & 63;
      if ((n4 & 224) == 192) {
        a3 += String.fromCharCode((n4 & 31) << 6 | r4);
        continue;
      }
      let i4 = e13[t3++] & 63;
      if (n4 = (n4 & 240) == 224 ? (n4 & 15) << 12 | r4 << 6 | i4 : (n4 & 7) << 18 | r4 << 12 | i4 << 6 | e13[t3++] & 63, n4 < 65536) a3 += String.fromCharCode(n4);
      else {
        let e14 = n4 - 65536;
        a3 += String.fromCharCode(55296 | e14 >> 10, 56320 | e14 & 1023);
      }
    }
    return a3;
  }
  function u2(e13, t3) {
    return e13 ? l2(r2.HEAPU8, e13, t3) : ``;
  }
  let d2 = { emscripten_get_now: Ai, emscripten_memcpy_big: a2, emscripten_resize_heap: s2, fd_write: () => 0 };
  async function f2() {
    let n3 = await e12({ env: d2, wasi_snapshot_preview1: d2 });
    t2 = n3.memory, i2(t2.buffer), Object.assign(r2, n3), r2.UTF8ToString = u2;
  }
  return await f2(), r2;
}
var Ni = Object.defineProperty, Pi = (e12, t2, n2) => t2 in e12 ? Ni(e12, t2, { enumerable: true, configurable: true, writable: true, value: n2 }) : e12[t2] = n2, Z = (e12, t2, n2) => Pi(e12, typeof t2 == `symbol` ? t2 : t2 + ``, n2), Q = null;
function Fi(e12) {
  throw new Oi(e12.UTF8ToString(e12.getLastOnigError()));
}
var Ii = class e10 {
  constructor(t2) {
    Z(this, `utf16Length`), Z(this, `utf8Length`), Z(this, `utf16Value`), Z(this, `utf8Value`), Z(this, `utf16OffsetToUtf8`), Z(this, `utf8OffsetToUtf16`);
    let n2 = t2.length, r2 = e10._utf8ByteLength(t2), i2 = r2 !== n2, a2 = i2 ? new Uint32Array(n2 + 1) : null;
    i2 && (a2[n2] = r2);
    let o2 = i2 ? new Uint32Array(r2 + 1) : null;
    i2 && (o2[r2] = n2);
    let s2 = new Uint8Array(r2), c2 = 0;
    for (let e12 = 0; e12 < n2; e12++) {
      let r3 = t2.charCodeAt(e12), l2 = r3, u2 = false;
      if (r3 >= 55296 && r3 <= 56319 && e12 + 1 < n2) {
        let n3 = t2.charCodeAt(e12 + 1);
        n3 >= 56320 && n3 <= 57343 && (l2 = (r3 - 55296 << 10) + 65536 | n3 - 56320, u2 = true);
      }
      i2 && (a2[e12] = c2, u2 && (a2[e12 + 1] = c2), l2 <= 127 ? o2[c2 + 0] = e12 : l2 <= 2047 ? (o2[c2 + 0] = e12, o2[c2 + 1] = e12) : l2 <= 65535 ? (o2[c2 + 0] = e12, o2[c2 + 1] = e12, o2[c2 + 2] = e12) : (o2[c2 + 0] = e12, o2[c2 + 1] = e12, o2[c2 + 2] = e12, o2[c2 + 3] = e12)), l2 <= 127 ? s2[c2++] = l2 : l2 <= 2047 ? (s2[c2++] = 192 | (l2 & 1984) >>> 6, s2[c2++] = 128 | (l2 & 63) >>> 0) : l2 <= 65535 ? (s2[c2++] = 224 | (l2 & 61440) >>> 12, s2[c2++] = 128 | (l2 & 4032) >>> 6, s2[c2++] = 128 | (l2 & 63) >>> 0) : (s2[c2++] = 240 | (l2 & 1835008) >>> 18, s2[c2++] = 128 | (l2 & 258048) >>> 12, s2[c2++] = 128 | (l2 & 4032) >>> 6, s2[c2++] = 128 | (l2 & 63) >>> 0), u2 && e12++;
    }
    this.utf16Length = n2, this.utf8Length = r2, this.utf16Value = t2, this.utf8Value = s2, this.utf16OffsetToUtf8 = a2, this.utf8OffsetToUtf16 = o2;
  }
  static _utf8ByteLength(e12) {
    let t2 = 0;
    for (let n2 = 0, r2 = e12.length; n2 < r2; n2++) {
      let i2 = e12.charCodeAt(n2), a2 = i2, o2 = false;
      if (i2 >= 55296 && i2 <= 56319 && n2 + 1 < r2) {
        let t3 = e12.charCodeAt(n2 + 1);
        t3 >= 56320 && t3 <= 57343 && (a2 = (i2 - 55296 << 10) + 65536 | t3 - 56320, o2 = true);
      }
      a2 <= 127 ? t2 += 1 : a2 <= 2047 ? t2 += 2 : a2 <= 65535 ? t2 += 3 : t2 += 4, o2 && n2++;
    }
    return t2;
  }
  createString(e12) {
    let t2 = e12.omalloc(this.utf8Length);
    return e12.HEAPU8.set(this.utf8Value, t2), t2;
  }
}, Li = class e11 {
  constructor(t2) {
    if (Z(this, `id`, ++e11.LAST_ID), Z(this, `_onigBinding`), Z(this, `content`), Z(this, `utf16Length`), Z(this, `utf8Length`), Z(this, `utf16OffsetToUtf8`), Z(this, `utf8OffsetToUtf16`), Z(this, `ptr`), !Q) throw new Oi(`Must invoke loadWasm first.`);
    this._onigBinding = Q, this.content = t2;
    let n2 = new Ii(t2);
    this.utf16Length = n2.utf16Length, this.utf8Length = n2.utf8Length, this.utf16OffsetToUtf8 = n2.utf16OffsetToUtf8, this.utf8OffsetToUtf16 = n2.utf8OffsetToUtf16, this.utf8Length < 1e4 && !e11._sharedPtrInUse ? (e11._sharedPtr || (e11._sharedPtr = Q.omalloc(1e4)), e11._sharedPtrInUse = true, Q.HEAPU8.set(n2.utf8Value, e11._sharedPtr), this.ptr = e11._sharedPtr) : this.ptr = n2.createString(Q);
  }
  convertUtf8OffsetToUtf16(e12) {
    return this.utf8OffsetToUtf16 ? e12 < 0 ? 0 : e12 > this.utf8Length ? this.utf16Length : this.utf8OffsetToUtf16[e12] : e12;
  }
  convertUtf16OffsetToUtf8(e12) {
    return this.utf16OffsetToUtf8 ? e12 < 0 ? 0 : e12 > this.utf16Length ? this.utf8Length : this.utf16OffsetToUtf8[e12] : e12;
  }
  dispose() {
    this.ptr === e11._sharedPtr ? e11._sharedPtrInUse = false : this._onigBinding.ofree(this.ptr);
  }
};
Z(Li, `LAST_ID`, 0), Z(Li, `_sharedPtr`, 0), Z(Li, `_sharedPtrInUse`, false);
var Ri = Li, zi = class {
  constructor(e12) {
    if (Z(this, `_onigBinding`), Z(this, `_ptr`), !Q) throw new Oi(`Must invoke loadWasm first.`);
    let t2 = [], n2 = [];
    for (let r3 = 0, i3 = e12.length; r3 < i3; r3++) {
      let i4 = new Ii(e12[r3]);
      t2[r3] = i4.createString(Q), n2[r3] = i4.utf8Length;
    }
    let r2 = Q.omalloc(4 * e12.length);
    Q.HEAPU32.set(t2, r2 / 4);
    let i2 = Q.omalloc(4 * e12.length);
    Q.HEAPU32.set(n2, i2 / 4);
    let a2 = Q.createOnigScanner(r2, i2, e12.length);
    for (let n3 = 0, r3 = e12.length; n3 < r3; n3++) Q.ofree(t2[n3]);
    Q.ofree(i2), Q.ofree(r2), a2 === 0 && Fi(Q), this._onigBinding = Q, this._ptr = a2;
  }
  dispose() {
    this._onigBinding.freeOnigScanner(this._ptr);
  }
  findNextMatchSync(e12, t2, n2) {
    let r2 = 0;
    if (typeof n2 == `number` && (r2 = n2), typeof e12 == `string`) {
      e12 = new Ri(e12);
      let n3 = this._findNextMatchSync(e12, t2, false, r2);
      return e12.dispose(), n3;
    }
    return this._findNextMatchSync(e12, t2, false, r2);
  }
  _findNextMatchSync(e12, t2, n2, r2) {
    let i2 = this._onigBinding, a2 = i2.findNextOnigScannerMatch(this._ptr, e12.id, e12.ptr, e12.utf8Length, e12.convertUtf16OffsetToUtf8(t2), r2);
    if (a2 === 0) return null;
    let o2 = i2.HEAPU32, s2 = a2 / 4, c2 = o2[s2++], l2 = o2[s2++], u2 = [];
    for (let t3 = 0; t3 < l2; t3++) {
      let n3 = e12.convertUtf8OffsetToUtf16(o2[s2++]), r3 = e12.convertUtf8OffsetToUtf16(o2[s2++]);
      u2[t3] = { start: n3, end: r3, length: r3 - n3 };
    }
    return { index: c2, captureIndices: u2 };
  }
};
function Bi(e12) {
  return typeof e12.instantiator == `function`;
}
function Vi(e12) {
  return typeof e12.default == `function`;
}
function Hi(e12) {
  return e12.data !== void 0;
}
function Ui(e12) {
  return typeof Response < `u` && e12 instanceof Response;
}
function Wi(e12) {
  return typeof ArrayBuffer < `u` && (e12 instanceof ArrayBuffer || ArrayBuffer.isView(e12)) || n !== void 0 && n.isBuffer?.(e12) || typeof SharedArrayBuffer < `u` && e12 instanceof SharedArrayBuffer || typeof Uint32Array < `u` && e12 instanceof Uint32Array;
}
var $;
function Gi(e12) {
  if ($) return $;
  async function t2() {
    Q = await Mi(async (t3) => {
      let n2 = e12;
      return n2 = await n2, typeof n2 == `function` && (n2 = await n2(t3)), typeof n2 == `function` && (n2 = await n2(t3)), Bi(n2) ? n2 = await n2.instantiator(t3) : Vi(n2) ? n2 = await n2.default(t3) : (Hi(n2) && (n2 = n2.data), Ui(n2) ? n2 = typeof WebAssembly.instantiateStreaming == `function` ? await qi(n2)(t3) : await Ji(n2)(t3) : Wi(n2) || n2 instanceof WebAssembly.Module ? n2 = await Ki(n2)(t3) : `default` in n2 && n2.default instanceof WebAssembly.Module && (n2 = await Ki(n2.default)(t3))), `instance` in n2 && (n2 = n2.instance), `exports` in n2 && (n2 = n2.exports), n2;
    });
  }
  return $ = t2(), $;
}
function Ki(e12) {
  return (t2) => WebAssembly.instantiate(e12, t2);
}
function qi(e12) {
  return (t2) => WebAssembly.instantiateStreaming(e12, t2);
}
function Ji(e12) {
  return async (t2) => {
    let n2 = await e12.arrayBuffer();
    return WebAssembly.instantiate(n2, t2);
  };
}
async function Yi(e12) {
  return e12 && await Gi(e12), { createScanner(e13) {
    return new zi(e13.map((e14) => typeof e14 == `string` ? e14 : e14.source));
  }, createString(e13) {
    return new Ri(e13);
  } };
}
export {
  Di as n,
  Yi as t
};
