import { j as b, k as R, c as C, T as d, b as E, N as o, C as _, R as y, g as I, Y as N, l as x, m as Q, e as q, P as H } from "./PlainValue-b8036b75.js";
var D = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i() {
    return C(this, i), v.call(this, d.BLANK_LINE);
  }
  return E(i, [{
    key: "includesTrailingLines",
    get: function() {
      return !0;
    }
  }, {
    key: "parse",
    value: function(r, e) {
      return this.context = r, this.range = new y(e, e + 1), e + 1;
    }
  }]), i;
}(o), K = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i(u, r) {
    var e;
    return C(this, i), e = v.call(this, u, r), e.node = null, e;
  }
  return E(i, [{
    key: "includesTrailingLines",
    get: function() {
      return !!this.node && this.node.includesTrailingLines;
    }
  }, {
    key: "parse",
    value: function(r, e) {
      this.context = r;
      var a = r.parseNode, t = r.src, l = r.atLineStart, s = r.lineStart;
      !l && this.type === d.SEQ_ITEM && (this.error = new I(this, "Sequence items must not have preceding content on the same line"));
      for (var c = l ? e - s : r.indent, n = o.endOfWhiteSpace(t, e + 1), h = t[n], f = h === "#", k = [], m = null; h === `
` || h === "#"; ) {
        if (h === "#") {
          var O = o.endOfLine(t, n + 1);
          k.push(new y(n, O)), n = O;
        } else {
          l = !0, s = n + 1;
          var g = o.endOfWhiteSpace(t, s);
          t[g] === `
` && k.length === 0 && (m = new D(), s = m.parse({
            src: t
          }, s)), n = o.endOfIndent(t, s);
        }
        h = t[n];
      }
      if (o.nextNodeIsIndented(h, n - (s + c), this.type !== d.SEQ_ITEM) ? this.node = a({
        atLineStart: l,
        inCollection: !1,
        indent: c,
        lineStart: s,
        parent: this
      }, n) : h && s > e + 1 && (n = s - 1), this.node) {
        if (m) {
          var S = r.parent.items || r.parent.contents;
          S && S.push(m);
        }
        k.length && Array.prototype.push.apply(this.props, k), n = this.node.range.end;
      } else if (f) {
        var w = k[0];
        this.props.push(w), n = w.end;
      } else
        n = o.endOfLine(t, e + 1);
      var M = this.node ? this.node.valueRange.end : n;
      return this.valueRange = new y(e, M), n;
    }
  }, {
    key: "setOrigRanges",
    value: function(r, e) {
      return e = x(Q(i.prototype), "setOrigRanges", this).call(this, r, e), this.node ? this.node.setOrigRanges(r, e) : e;
    }
  }, {
    key: "toString",
    value: function() {
      var r = this.context.src, e = this.node, a = this.range, t = this.value;
      if (t != null)
        return t;
      var l = e ? r.slice(a.start, e.range.start) + String(e) : r.slice(a.start, a.end);
      return o.addStringTerminator(r, a.end, l);
    }
  }]), i;
}(o), B = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i() {
    return C(this, i), v.call(this, d.COMMENT);
  }
  return E(i, [{
    key: "parse",
    value: function(r, e) {
      this.context = r;
      var a = this.parseComment(e);
      return this.range = new y(e, a), a;
    }
  }]), i;
}(o);
function F(p) {
  for (var v = p; v instanceof K; )
    v = v.node;
  if (!(v instanceof U))
    return null;
  for (var i = v.items.length, u = -1, r = i - 1; r >= 0; --r) {
    var e = v.items[r];
    if (e.type === d.COMMENT) {
      var a = e.context, t = a.indent, l = a.lineStart;
      if (t > 0 && e.range.start >= l + t)
        break;
      u = r;
    } else if (e.type === d.BLANK_LINE)
      u = r;
    else
      break;
  }
  if (u === -1)
    return null;
  for (var s = v.items.splice(u, i - u), c = s[0].range.start; v.range.end = c, v.valueRange && v.valueRange.end > c && (v.valueRange.end = c), v !== p; )
    v = v.context.parent;
  return s;
}
var U = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i(u) {
    var r;
    C(this, i), r = v.call(this, u.type === d.SEQ_ITEM ? d.SEQ : d.MAP);
    for (var e = u.props.length - 1; e >= 0; --e)
      if (u.props[e].start < u.context.lineStart) {
        r.props = u.props.slice(0, e + 1), u.props = u.props.slice(e + 1);
        var a = u.props[0] || u.valueRange;
        u.range.start = a.start;
        break;
      }
    r.items = [u];
    var t = F(u);
    return t && Array.prototype.push.apply(r.items, t), r;
  }
  return E(i, [{
    key: "includesTrailingLines",
    get: function() {
      return this.items.length > 0;
    }
  }, {
    key: "parse",
    value: function(r, e) {
      this.context = r;
      var a = r.parseNode, t = r.src, l = o.startOfLine(t, e), s = this.items[0];
      s.context.parent = this, this.valueRange = y.copy(s.valueRange);
      var c = s.range.start - s.context.lineStart, n = e;
      n = o.normalizeOffset(t, n);
      for (var h = t[n], f = o.endOfWhiteSpace(t, l) === n, k = !1; h; ) {
        for (; h === `
` || h === "#"; ) {
          if (f && h === `
` && !k) {
            var m = new D();
            if (n = m.parse({
              src: t
            }, n), this.valueRange.end = n, n >= t.length) {
              h = null;
              break;
            }
            this.items.push(m), n -= 1;
          } else if (h === "#") {
            if (n < l + c && !i.nextContentHasIndent(t, n, c))
              return n;
            var O = new B();
            if (n = O.parse({
              indent: c,
              lineStart: l,
              src: t
            }, n), this.items.push(O), this.valueRange.end = n, n >= t.length) {
              h = null;
              break;
            }
          }
          if (l = n + 1, n = o.endOfIndent(t, l), o.atBlank(t, n)) {
            var g = o.endOfWhiteSpace(t, n), S = t[g];
            (!S || S === `
` || S === "#") && (n = g);
          }
          h = t[n], f = !0;
        }
        if (!h)
          break;
        if (n !== l + c && (f || h !== ":")) {
          if (n < l + c) {
            l > e && (n = l);
            break;
          } else if (!this.error) {
            var w = "All collection items must start at the same column";
            this.error = new N(this, w);
          }
        }
        if (s.type === d.SEQ_ITEM) {
          if (h !== "-") {
            l > e && (n = l);
            break;
          }
        } else if (h === "-" && !this.error) {
          var M = t[n + 1];
          if (!M || M === `
` || M === "	" || M === " ") {
            var A = "A collection cannot be both a mapping and a sequence";
            this.error = new N(this, A);
          }
        }
        var L = a({
          atLineStart: f,
          inCollection: !0,
          indent: c,
          lineStart: l,
          parent: this
        }, n);
        if (!L)
          return n;
        if (this.items.push(L), this.valueRange.end = L.valueRange.end, n = o.normalizeOffset(t, L.range.end), h = t[n], f = !1, k = L.includesTrailingLines, h) {
          for (var P = n - 1, W = t[P]; W === " " || W === "	"; )
            W = t[--P];
          W === `
` && (l = P + 1, f = !0);
        }
        var V = F(L);
        V && Array.prototype.push.apply(this.items, V);
      }
      return n;
    }
  }, {
    key: "setOrigRanges",
    value: function(r, e) {
      return e = x(Q(i.prototype), "setOrigRanges", this).call(this, r, e), this.items.forEach(function(a) {
        e = a.setOrigRanges(r, e);
      }), e;
    }
  }, {
    key: "toString",
    value: function() {
      var r = this.context.src, e = this.items, a = this.range, t = this.value;
      if (t != null)
        return t;
      for (var l = r.slice(a.start, e[0].range.start) + String(e[0]), s = 1; s < e.length; ++s) {
        var c = e[s], n = c.context, h = n.atLineStart, f = n.indent;
        if (h)
          for (var k = 0; k < f; ++k)
            l += " ";
        l += String(c);
      }
      return o.addStringTerminator(r, a.end, l);
    }
  }], [{
    key: "nextContentHasIndent",
    value: function(r, e, a) {
      var t = o.endOfLine(r, e) + 1;
      e = o.endOfWhiteSpace(r, t);
      var l = r[e];
      return l ? e >= t + a ? !0 : l !== "#" && l !== `
` ? !1 : i.nextContentHasIndent(r, e, a) : !1;
    }
  }]), i;
}(o), z = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i() {
    var u;
    return C(this, i), u = v.call(this, d.DIRECTIVE), u.name = null, u;
  }
  return E(i, [{
    key: "parameters",
    get: function() {
      var r = this.rawValue;
      return r ? r.trim().split(/[ \t]+/) : [];
    }
  }, {
    key: "parseName",
    value: function(r) {
      for (var e = this.context.src, a = r, t = e[a]; t && t !== `
` && t !== "	" && t !== " "; )
        t = e[a += 1];
      return this.name = e.slice(r, a), a;
    }
  }, {
    key: "parseParameters",
    value: function(r) {
      for (var e = this.context.src, a = r, t = e[a]; t && t !== `
` && t !== "#"; )
        t = e[a += 1];
      return this.valueRange = new y(r, a), a;
    }
  }, {
    key: "parse",
    value: function(r, e) {
      this.context = r;
      var a = this.parseName(e + 1);
      return a = this.parseParameters(a), a = this.parseComment(a), this.range = new y(e, a), a;
    }
  }]), i;
}(o), Y = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i() {
    var u;
    return C(this, i), u = v.call(this, d.DOCUMENT), u.directives = null, u.contents = null, u.directivesEndMarker = null, u.documentEndMarker = null, u;
  }
  return E(i, [{
    key: "parseDirectives",
    value: function(r) {
      var e = this.context.src;
      this.directives = [];
      for (var a = !0, t = !1, l = r; !o.atDocumentBoundary(e, l, _.DIRECTIVES_END); )
        switch (l = i.startCommentOrEndBlankLine(e, l), e[l]) {
          case `
`:
            if (a) {
              var s = new D();
              l = s.parse({
                src: e
              }, l), l < e.length && this.directives.push(s);
            } else
              l += 1, a = !0;
            break;
          case "#":
            {
              var c = new B();
              l = c.parse({
                src: e
              }, l), this.directives.push(c), a = !1;
            }
            break;
          case "%":
            {
              var n = new z();
              l = n.parse({
                parent: this,
                src: e
              }, l), this.directives.push(n), t = !0, a = !1;
            }
            break;
          default:
            return t ? this.error = new I(this, "Missing directives-end indicator line") : this.directives.length > 0 && (this.contents = this.directives, this.directives = []), l;
        }
      return e[l] ? (this.directivesEndMarker = new y(l, l + 3), l + 3) : (t ? this.error = new I(this, "Missing directives-end indicator line") : this.directives.length > 0 && (this.contents = this.directives, this.directives = []), l);
    }
  }, {
    key: "parseContents",
    value: function(r) {
      var e = this.context, a = e.parseNode, t = e.src;
      this.contents || (this.contents = []);
      for (var l = r; t[l - 1] === "-"; )
        l -= 1;
      var s = o.endOfWhiteSpace(t, r), c = l === r;
      for (this.valueRange = new y(s); !o.atDocumentBoundary(t, s, _.DOCUMENT_END); ) {
        switch (t[s]) {
          case `
`:
            if (c) {
              var n = new D();
              s = n.parse({
                src: t
              }, s), s < t.length && this.contents.push(n);
            } else
              s += 1, c = !0;
            l = s;
            break;
          case "#":
            {
              var h = new B();
              s = h.parse({
                src: t
              }, s), this.contents.push(h), c = !1;
            }
            break;
          default: {
            var f = o.endOfIndent(t, s), k = {
              atLineStart: c,
              indent: -1,
              inFlow: !1,
              inCollection: !1,
              lineStart: l,
              parent: this
            }, m = a(k, f);
            if (!m)
              return this.valueRange.end = f;
            this.contents.push(m), s = m.range.end, c = !1;
            var O = F(m);
            O && Array.prototype.push.apply(this.contents, O);
          }
        }
        s = i.startCommentOrEndBlankLine(t, s);
      }
      if (this.valueRange.end = s, t[s] && (this.documentEndMarker = new y(s, s + 3), s += 3, t[s])) {
        if (s = o.endOfWhiteSpace(t, s), t[s] === "#") {
          var g = new B();
          s = g.parse({
            src: t
          }, s), this.contents.push(g);
        }
        switch (t[s]) {
          case `
`:
            s += 1;
            break;
          case void 0:
            break;
          default:
            this.error = new N(this, "Document end marker line cannot have a non-comment suffix");
        }
      }
      return s;
    }
  }, {
    key: "parse",
    value: function(r, e) {
      r.root = this, this.context = r;
      var a = r.src, t = a.charCodeAt(e) === 65279 ? e + 1 : e;
      return t = this.parseDirectives(t), t = this.parseContents(t), t;
    }
  }, {
    key: "setOrigRanges",
    value: function(r, e) {
      return e = x(Q(i.prototype), "setOrigRanges", this).call(this, r, e), this.directives.forEach(function(a) {
        e = a.setOrigRanges(r, e);
      }), this.directivesEndMarker && (e = this.directivesEndMarker.setOrigRange(r, e)), this.contents.forEach(function(a) {
        e = a.setOrigRanges(r, e);
      }), this.documentEndMarker && (e = this.documentEndMarker.setOrigRange(r, e)), e;
    }
  }, {
    key: "toString",
    value: function() {
      var r = this.contents, e = this.directives, a = this.value;
      if (a != null)
        return a;
      var t = e.join("");
      return r.length > 0 && ((e.length > 0 || r[0].type === d.COMMENT) && (t += `---
`), t += r.join("")), t[t.length - 1] !== `
` && (t += `
`), t;
    }
  }], [{
    key: "startCommentOrEndBlankLine",
    value: function(r, e) {
      var a = o.endOfWhiteSpace(r, e), t = r[a];
      return t === "#" || t === `
` ? a : e;
    }
  }]), i;
}(o), j = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i() {
    return C(this, i), v.apply(this, arguments);
  }
  return E(i, [{
    key: "parse",
    value: function(r, e) {
      this.context = r;
      var a = r.src, t = o.endOfIdentifier(a, e + 1);
      return this.valueRange = new y(e + 1, t), t = o.endOfWhiteSpace(a, t), t = this.parseComment(t), t;
    }
  }]), i;
}(o), T = {
  CLIP: "CLIP",
  KEEP: "KEEP",
  STRIP: "STRIP"
}, G = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i(u, r) {
    var e;
    return C(this, i), e = v.call(this, u, r), e.blockIndent = null, e.chomping = T.CLIP, e.header = null, e;
  }
  return E(i, [{
    key: "includesTrailingLines",
    get: function() {
      return this.chomping === T.KEEP;
    }
  }, {
    key: "strValue",
    get: function() {
      if (!this.valueRange || !this.context)
        return null;
      var r = this.valueRange, e = r.start, a = r.end, t = this.context, l = t.indent, s = t.src;
      if (this.valueRange.isEmpty())
        return "";
      for (var c = null, n = s[a - 1]; n === `
` || n === "	" || n === " "; ) {
        if (a -= 1, a <= e) {
          if (this.chomping === T.KEEP)
            break;
          return "";
        }
        n === `
` && (c = a), n = s[a - 1];
      }
      var h = a + 1;
      c && (this.chomping === T.KEEP ? (h = c, a = this.valueRange.end) : a = c);
      for (var f = l + this.blockIndent, k = this.type === d.BLOCK_FOLDED, m = !0, O = "", g = "", S = !1, w = e; w < a; ++w) {
        for (var M = 0; M < f && s[w] === " "; ++M)
          w += 1;
        var A = s[w];
        if (A === `
`)
          g === `
` ? O += `
` : g = `
`;
        else {
          var L = o.endOfLine(s, w), P = s.slice(w, L);
          w = L, k && (A === " " || A === "	") && w < h ? (g === " " ? g = `
` : !S && !m && g === `
` && (g = `

`), O += g + P, g = L < a && s[L] || "", S = !0) : (O += g + P, g = k && w < h ? " " : `
`, S = !1), m && P !== "" && (m = !1);
        }
      }
      return this.chomping === T.STRIP ? O : O + `
`;
    }
  }, {
    key: "parseBlockHeader",
    value: function(r) {
      for (var e = this.context.src, a = r + 1, t = ""; ; ) {
        var l = e[a];
        switch (l) {
          case "-":
            this.chomping = T.STRIP;
            break;
          case "+":
            this.chomping = T.KEEP;
            break;
          case "0":
          case "1":
          case "2":
          case "3":
          case "4":
          case "5":
          case "6":
          case "7":
          case "8":
          case "9":
            t += l;
            break;
          default:
            return this.blockIndent = Number(t) || null, this.header = new y(r, a), a;
        }
        a += 1;
      }
    }
  }, {
    key: "parseBlockValue",
    value: function(r) {
      for (var e = this.context, a = e.indent, t = e.src, l = !!this.blockIndent, s = r, c = r, n = 1, h = t[s]; h === `
` && (s += 1, !o.atDocumentBoundary(t, s)); h = t[s]) {
        var f = o.endOfBlockIndent(t, a, s);
        if (f === null)
          break;
        var k = t[f], m = f - (s + a);
        if (this.blockIndent) {
          if (k && k !== `
` && m < this.blockIndent) {
            if (t[f] === "#")
              break;
            if (!this.error) {
              var g = l ? "explicit indentation indicator" : "first line", S = "Block scalars must not be less indented than their ".concat(g);
              this.error = new I(this, S);
            }
          }
        } else if (t[f] !== `
`) {
          if (m < n) {
            var O = "Block scalars with more-indented leading empty lines must use an explicit indentation indicator";
            this.error = new I(this, O);
          }
          this.blockIndent = m;
        } else
          m > n && (n = m);
        t[f] === `
` ? s = f : s = c = o.endOfLine(t, f);
      }
      return this.chomping !== T.KEEP && (s = t[c] ? c + 1 : c), this.valueRange = new y(r + 1, s), s;
    }
  }, {
    key: "parse",
    value: function(r, e) {
      this.context = r;
      var a = r.src, t = this.parseBlockHeader(e);
      return t = o.endOfWhiteSpace(a, t), t = this.parseComment(t), t = this.parseBlockValue(t), t;
    }
  }, {
    key: "setOrigRanges",
    value: function(r, e) {
      return e = x(Q(i.prototype), "setOrigRanges", this).call(this, r, e), this.header ? this.header.setOrigRange(r, e) : e;
    }
  }]), i;
}(o), J = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i(u, r) {
    var e;
    return C(this, i), e = v.call(this, u, r), e.items = null, e;
  }
  return E(i, [{
    key: "prevNodeIsJsonLike",
    value: function() {
      var r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.items.length, e = this.items[r - 1];
      return !!e && (e.jsonLike || e.type === d.COMMENT && this.prevNodeIsJsonLike(r - 1));
    }
  }, {
    key: "parse",
    value: function(r, e) {
      this.context = r;
      var a = r.parseNode, t = r.src, l = r.indent, s = r.lineStart, c = t[e];
      this.items = [{
        char: c,
        offset: e
      }];
      var n = o.endOfWhiteSpace(t, e + 1);
      for (c = t[n]; c && c !== "]" && c !== "}"; ) {
        switch (c) {
          case `
`:
            {
              s = n + 1;
              var h = o.endOfWhiteSpace(t, s);
              if (t[h] === `
`) {
                var f = new D();
                s = f.parse({
                  src: t
                }, s), this.items.push(f);
              }
              if (n = o.endOfIndent(t, s), n <= s + l && (c = t[n], n < s + l || c !== "]" && c !== "}")) {
                var k = "Insufficient indentation in flow collection";
                this.error = new I(this, k);
              }
            }
            break;
          case ",":
            this.items.push({
              char: c,
              offset: n
            }), n += 1;
            break;
          case "#":
            {
              var m = new B();
              n = m.parse({
                src: t
              }, n), this.items.push(m);
            }
            break;
          case "?":
          case ":": {
            var O = t[n + 1];
            if (O === `
` || O === "	" || O === " " || O === "," || c === ":" && this.prevNodeIsJsonLike()) {
              this.items.push({
                char: c,
                offset: n
              }), n += 1;
              break;
            }
          }
          default: {
            var g = a({
              atLineStart: !1,
              inCollection: !1,
              inFlow: !0,
              indent: -1,
              lineStart: s,
              parent: this
            }, n);
            if (!g)
              return this.valueRange = new y(e, n), n;
            this.items.push(g), n = o.normalizeOffset(t, g.range.end);
          }
        }
        n = o.endOfWhiteSpace(t, n), c = t[n];
      }
      return this.valueRange = new y(e, n + 1), c && (this.items.push({
        char: c,
        offset: n
      }), n = o.endOfWhiteSpace(t, n + 1), n = this.parseComment(n)), n;
    }
  }, {
    key: "setOrigRanges",
    value: function(r, e) {
      return e = x(Q(i.prototype), "setOrigRanges", this).call(this, r, e), this.items.forEach(function(a) {
        if (a instanceof o)
          e = a.setOrigRanges(r, e);
        else if (r.length === 0)
          a.origOffset = a.offset;
        else {
          for (var t = e; t < r.length && !(r[t] > a.offset); )
            ++t;
          a.origOffset = a.offset + t, e = t;
        }
      }), e;
    }
  }, {
    key: "toString",
    value: function() {
      var r = this.context.src, e = this.items, a = this.range, t = this.value;
      if (t != null)
        return t;
      var l = e.filter(function(n) {
        return n instanceof o;
      }), s = "", c = a.start;
      return l.forEach(function(n) {
        var h = r.slice(c, n.range.start);
        c = n.range.end, s += h + String(n), s[s.length - 1] === `
` && r[c - 1] !== `
` && r[c] === `
` && (c += 1);
      }), s += r.slice(c, a.end), o.addStringTerminator(r, a.end, s);
    }
  }]), i;
}(o), $ = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i() {
    return C(this, i), v.apply(this, arguments);
  }
  return E(i, [{
    key: "strValue",
    get: function() {
      if (!this.valueRange || !this.context)
        return null;
      var r = [], e = this.valueRange, a = e.start, t = e.end, l = this.context, s = l.indent, c = l.src;
      c[t - 1] !== '"' && r.push(new N(this, 'Missing closing "quote'));
      for (var n = "", h = a + 1; h < t - 1; ++h) {
        var f = c[h];
        if (f === `
`) {
          o.atDocumentBoundary(c, h + 1) && r.push(new I(this, "Document boundary indicators are not allowed within string values"));
          var k = o.foldNewline(c, h, s), m = k.fold, O = k.offset, g = k.error;
          n += m, h = O, g && r.push(new I(this, "Multi-line double-quoted string needs to be sufficiently indented"));
        } else if (f === "\\")
          switch (h += 1, c[h]) {
            case "0":
              n += "\0";
              break;
            case "a":
              n += "\x07";
              break;
            case "b":
              n += "\b";
              break;
            case "e":
              n += "\x1B";
              break;
            case "f":
              n += "\f";
              break;
            case "n":
              n += `
`;
              break;
            case "r":
              n += "\r";
              break;
            case "t":
              n += "	";
              break;
            case "v":
              n += "\v";
              break;
            case "N":
              n += "\x85";
              break;
            case "_":
              n += "\xA0";
              break;
            case "L":
              n += "\u2028";
              break;
            case "P":
              n += "\u2029";
              break;
            case " ":
              n += " ";
              break;
            case '"':
              n += '"';
              break;
            case "/":
              n += "/";
              break;
            case "\\":
              n += "\\";
              break;
            case "	":
              n += "	";
              break;
            case "x":
              n += this.parseCharCode(h + 1, 2, r), h += 2;
              break;
            case "u":
              n += this.parseCharCode(h + 1, 4, r), h += 4;
              break;
            case "U":
              n += this.parseCharCode(h + 1, 8, r), h += 8;
              break;
            case `
`:
              for (; c[h + 1] === " " || c[h + 1] === "	"; )
                h += 1;
              break;
            default:
              r.push(new N(this, "Invalid escape sequence ".concat(c.substr(h - 1, 2)))), n += "\\" + c[h];
          }
        else if (f === " " || f === "	") {
          for (var S = h, w = c[h + 1]; w === " " || w === "	"; )
            h += 1, w = c[h + 1];
          w !== `
` && (n += h > S ? c.slice(S, h + 1) : f);
        } else
          n += f;
      }
      return r.length > 0 ? {
        errors: r,
        str: n
      } : n;
    }
  }, {
    key: "parseCharCode",
    value: function(r, e, a) {
      var t = this.context.src, l = t.substr(r, e), s = l.length === e && /^[0-9a-fA-F]+$/.test(l), c = s ? parseInt(l, 16) : NaN;
      return isNaN(c) ? (a.push(new N(this, "Invalid escape sequence ".concat(t.substr(r - 2, e + 2)))), t.substr(r - 2, e + 2)) : String.fromCodePoint(c);
    }
  }, {
    key: "parse",
    value: function(r, e) {
      this.context = r;
      var a = r.src, t = i.endOfQuote(a, e + 1);
      return this.valueRange = new y(e, t), t = o.endOfWhiteSpace(a, t), t = this.parseComment(t), t;
    }
  }], [{
    key: "endOfQuote",
    value: function(r, e) {
      for (var a = r[e]; a && a !== '"'; )
        e += a === "\\" ? 2 : 1, a = r[e];
      return e + 1;
    }
  }]), i;
}(o), Z = /* @__PURE__ */ function(p) {
  b(i, p);
  var v = R(i);
  function i() {
    return C(this, i), v.apply(this, arguments);
  }
  return E(i, [{
    key: "strValue",
    get: function() {
      if (!this.valueRange || !this.context)
        return null;
      var r = [], e = this.valueRange, a = e.start, t = e.end, l = this.context, s = l.indent, c = l.src;
      c[t - 1] !== "'" && r.push(new N(this, "Missing closing 'quote"));
      for (var n = "", h = a + 1; h < t - 1; ++h) {
        var f = c[h];
        if (f === `
`) {
          o.atDocumentBoundary(c, h + 1) && r.push(new I(this, "Document boundary indicators are not allowed within string values"));
          var k = o.foldNewline(c, h, s), m = k.fold, O = k.offset, g = k.error;
          n += m, h = O, g && r.push(new I(this, "Multi-line single-quoted string needs to be sufficiently indented"));
        } else if (f === "'")
          n += f, h += 1, c[h] !== "'" && r.push(new N(this, "Unescaped single quote? This should not happen."));
        else if (f === " " || f === "	") {
          for (var S = h, w = c[h + 1]; w === " " || w === "	"; )
            h += 1, w = c[h + 1];
          w !== `
` && (n += h > S ? c.slice(S, h + 1) : f);
        } else
          n += f;
      }
      return r.length > 0 ? {
        errors: r,
        str: n
      } : n;
    }
  }, {
    key: "parse",
    value: function(r, e) {
      this.context = r;
      var a = r.src, t = i.endOfQuote(a, e + 1);
      return this.valueRange = new y(e, t), t = o.endOfWhiteSpace(a, t), t = this.parseComment(t), t;
    }
  }], [{
    key: "endOfQuote",
    value: function(r, e) {
      for (var a = r[e]; a; )
        if (a === "'") {
          if (r[e + 1] !== "'")
            break;
          a = r[e += 2];
        } else
          a = r[e += 1];
      return e + 1;
    }
  }]), i;
}(o);
function X(p, v) {
  switch (p) {
    case d.ALIAS:
      return new j(p, v);
    case d.BLOCK_FOLDED:
    case d.BLOCK_LITERAL:
      return new G(p, v);
    case d.FLOW_MAP:
    case d.FLOW_SEQ:
      return new J(p, v);
    case d.MAP_KEY:
    case d.MAP_VALUE:
    case d.SEQ_ITEM:
      return new K(p, v);
    case d.COMMENT:
    case d.PLAIN:
      return new H(p, v);
    case d.QUOTE_DOUBLE:
      return new $(p, v);
    case d.QUOTE_SINGLE:
      return new Z(p, v);
    default:
      return null;
  }
}
var ee = /* @__PURE__ */ function() {
  function p() {
    var v = this, i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, u = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = u.atLineStart, e = u.inCollection, a = u.inFlow, t = u.indent, l = u.lineStart, s = u.parent;
    C(this, p), q(this, "parseNode", function(c, n) {
      if (o.atDocumentBoundary(v.src, n))
        return null;
      var h = new p(v, c), f = h.parseProps(n), k = f.props, m = f.type, O = f.valueStart, g = X(m, k), S = g.parse(h, O);
      if (g.range = new y(n, S), S <= n && (g.error = new Error("Node#parse consumed no characters"), g.error.parseEnd = S, g.error.source = g, g.range.end = n + 1), h.nodeStartsCollection(g)) {
        !g.error && !h.atLineStart && h.parent.type === d.DOCUMENT && (g.error = new N(g, "Block collection must not have preceding content here (e.g. directives-end indicator)"));
        var w = new U(g);
        return S = w.parse(new p(h), S), w.range = new y(n, S), w;
      }
      return g;
    }), this.atLineStart = r != null ? r : i.atLineStart || !1, this.inCollection = e != null ? e : i.inCollection || !1, this.inFlow = a != null ? a : i.inFlow || !1, this.indent = t != null ? t : i.indent, this.lineStart = l != null ? l : i.lineStart, this.parent = s != null ? s : i.parent || {}, this.root = i.root, this.src = i.src;
  }
  return E(p, [{
    key: "nodeStartsCollection",
    value: function(i) {
      var u = this.inCollection, r = this.inFlow, e = this.src;
      if (u || r)
        return !1;
      if (i instanceof K)
        return !0;
      var a = i.range.end;
      return e[a] === `
` || e[a - 1] === `
` ? !1 : (a = o.endOfWhiteSpace(e, a), e[a] === ":");
    }
  }, {
    key: "parseProps",
    value: function(i) {
      var u = this.inFlow, r = this.parent, e = this.src, a = [], t = !1;
      i = this.atLineStart ? o.endOfIndent(e, i) : o.endOfWhiteSpace(e, i);
      for (var l = e[i]; l === _.ANCHOR || l === _.COMMENT || l === _.TAG || l === `
`; ) {
        if (l === `
`) {
          var s = i, c = void 0;
          do
            c = s + 1, s = o.endOfIndent(e, c);
          while (e[s] === `
`);
          var n = s - (c + this.indent), h = r.type === d.SEQ_ITEM && r.context.atLineStart;
          if (e[s] !== "#" && !o.nextNodeIsIndented(e[s], n, !h))
            break;
          this.atLineStart = !0, this.lineStart = c, t = !1, i = s;
        } else if (l === _.COMMENT) {
          var f = o.endOfLine(e, i + 1);
          a.push(new y(i, f)), i = f;
        } else {
          var k = o.endOfIdentifier(e, i + 1);
          l === _.TAG && e[k] === "," && /^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(e.slice(i + 1, k + 13)) && (k = o.endOfIdentifier(e, k + 5)), a.push(new y(i, k)), t = !0, i = o.endOfWhiteSpace(e, k);
        }
        l = e[i];
      }
      t && l === ":" && o.atBlank(e, i + 1, !0) && (i -= 1);
      var m = p.parseType(e, i, u);
      return {
        props: a,
        type: m,
        valueStart: i
      };
    }
  }], [{
    key: "parseType",
    value: function(i, u, r) {
      switch (i[u]) {
        case "*":
          return d.ALIAS;
        case ">":
          return d.BLOCK_FOLDED;
        case "|":
          return d.BLOCK_LITERAL;
        case "{":
          return d.FLOW_MAP;
        case "[":
          return d.FLOW_SEQ;
        case "?":
          return !r && o.atBlank(i, u + 1, !0) ? d.MAP_KEY : d.PLAIN;
        case ":":
          return !r && o.atBlank(i, u + 1, !0) ? d.MAP_VALUE : d.PLAIN;
        case "-":
          return !r && o.atBlank(i, u + 1, !0) ? d.SEQ_ITEM : d.PLAIN;
        case '"':
          return d.QUOTE_DOUBLE;
        case "'":
          return d.QUOTE_SINGLE;
        default:
          return d.PLAIN;
      }
    }
  }]), p;
}();
function re(p) {
  var v = [];
  p.indexOf("\r") !== -1 && (p = p.replace(/\r\n?/g, function(a, t) {
    return a.length > 1 && v.push(t), `
`;
  }));
  var i = [], u = 0;
  do {
    var r = new Y(), e = new ee({
      src: p
    });
    u = r.parse(e, u), i.push(r);
  } while (u < p.length);
  return i.setOrigRanges = function() {
    if (v.length === 0)
      return !1;
    for (var a = 1; a < v.length; ++a)
      v[a] -= a;
    for (var t = 0, l = 0; l < i.length; ++l)
      t = i[l].setOrigRanges(v, t);
    return v.splice(0, v.length), !0;
  }, i.toString = function() {
    return i.join(`...
`);
  }, i;
}
export {
  re as parse
};
//# sourceMappingURL=parse-cst.js.map
