@shopify/create-app
Version:
A CLI tool to create a new Shopify app.
1,354 lines (1,353 loc) • 177 kB
JavaScript
import {
__esm,
init_cjs_shims
} from "./chunk-PKR7KJ6P.js";
// ../../node_modules/.pnpm/prettier@3.7.4/node_modules/prettier/plugins/yaml.mjs
function Ri(t) {
return this[t < 0 ? this.length + t : t];
}
function Fi(t) {
if (typeof t == "string") return Qe;
if (Array.isArray(t)) return Ge;
if (!t) return;
let { type: e } = t;
if (bt.has(e)) return e;
}
function Ui(t) {
let e = t === null ? "null" : typeof t;
if (e !== "string" && e !== "object") return `Unexpected doc '${e}',
Expected it to be 'string' or 'object'.`;
if (Nt(t)) throw new Error("doc is valid.");
let n = Object.prototype.toString.call(t);
if (n !== "[object Object]") return `Unexpected doc '${n}'.`;
let r = qi([...bt].map((s) => `'${s}'`));
return `Unexpected doc.type '${t.type}'.
Expected it to be ${r}.`;
}
function Vi(t, e) {
if (typeof t == "string") return e(t);
let n = /* @__PURE__ */ new Map();
return r(t);
function r(i) {
if (n.has(i)) return n.get(i);
let o = s(i);
return n.set(i, o), o;
}
function s(i) {
switch (Nt(i)) {
case Ge:
return e(i.map(r));
case Te:
return e({ ...i, parts: i.parts.map(r) });
case Ce:
return e({ ...i, breakContents: r(i.breakContents), flatContents: r(i.flatContents) });
case Le: {
let { expandedStates: o, contents: a } = i;
return o ? (o = o.map(r), a = o[0]) : a = r(a), e({ ...i, contents: a, expandedStates: o });
}
case Ae:
case gt:
case Et:
case wt:
case Me:
return e({ ...i, contents: r(i.contents) });
case Qe:
case dt:
case yt:
case St:
case re:
case ke:
return e(i);
default:
throw new ar(i);
}
}
}
function cr(t, e = He) {
return Vi(t, (n) => typeof n == "string" ? v(e, n.split(`
`)) : n);
}
function Je(t, e) {
return fr(t), Z(e), { type: Ae, contents: e, n: t };
}
function cn(t) {
return Je(Number.NEGATIVE_INFINITY, t);
}
function ur(t) {
return Je({ type: "root" }, t);
}
function pr(t) {
return Je(-1, t);
}
function At(t) {
return lr(t), { type: Te, parts: t };
}
function Pe(t, e = {}) {
return Z(t), Ot(e.expandedStates, !0), { type: Le, id: e.id, contents: t, break: !!e.shouldBreak, expandedStates: e.expandedStates };
}
function ln(t, e) {
return Pe(t[0], { ...e, expandedStates: t });
}
function ze(t, e = "", n = {}) {
return Z(t), e !== "" && Z(e), { type: Ce, breakContents: t, flatContents: e, groupId: n.groupId };
}
function v(t, e) {
Z(t), Ot(e);
let n = [];
for (let r = 0; r < e.length; r++) r !== 0 && n.push(t), n.push(e[r]);
return n;
}
function mr(t) {
return Z(t), { type: Me, contents: t };
}
function Tt(t) {
return (e, n, r) => {
let s = !!r?.backwards;
if (n === !1) return !1;
let { length: i } = e, o = n;
for (; o >= 0 && o < i; ) {
let a = e.charAt(o);
if (t instanceof RegExp) {
if (!t.test(a)) return o;
} else if (!t.includes(a)) return o;
s ? o-- : o++;
}
return o === -1 || o === i ? o : !1;
};
}
function ji(t, e, n) {
let r = !!n?.backwards;
if (e === !1) return !1;
let s = t.charAt(e);
if (r) {
if (t.charAt(e - 1) === "\r" && s === `
`) return e - 2;
if (hr(s)) return e - 1;
} else {
if (s === "\r" && t.charAt(e + 1) === `
`) return e + 2;
if (hr(s)) return e + 1;
}
return e;
}
function Qi(t, e) {
let n = e - 1;
n = fn(t, n, { backwards: !0 }), n = un(t, n, { backwards: !0 }), n = fn(t, n, { backwards: !0 });
let r = un(t, n, { backwards: !0 });
return n !== r;
}
function Ar(t, e) {
switch (t.type) {
case "comment":
if (wr(t.value)) return null;
break;
case "quoteDouble":
case "quoteSingle":
e.type = "quote";
break;
case "document":
e.directivesEndMarker || delete e.directivesEndMarker, e.documentEndMarker || delete e.documentEndMarker;
break;
}
}
function Tr(t, e) {
let { node: n } = t;
if (n.type === "root" && e.filepath && /(?:[/\\]|^)\.(?:prettier|stylelint|lintstaged)rc$/u.test(e.filepath)) return async (r) => {
let s = await r(e.originalText, { parser: "json" });
return s ? [s, N] : void 0;
};
}
function et(t) {
if (Ze !== null && typeof Ze.property) {
let e = Ze;
return Ze = et.prototype = null, e;
}
return Ze = et.prototype = t ?? /* @__PURE__ */ Object.create(null), new et();
}
function hn(t) {
return et(t);
}
function Hi(t, e = "type") {
hn(t);
function n(r) {
let s = r[e], i = t[s];
if (!Array.isArray(i)) throw Object.assign(new Error(`Missing visitor keys for '${s}'.`), { node: r });
return i;
}
return n;
}
function Xi(t) {
return Array.isArray(t) && t.length > 0;
}
function W(t, e) {
return typeof t?.type == "string" && e.includes(t.type);
}
function dn(t, e, n) {
return e("children" in t ? { ...t, children: t.children.map((r) => dn(r, e, t)) } : t, n);
}
function Ie(t, e, n) {
Object.defineProperty(t, e, { get: n, enumerable: !1 });
}
function _r(t, e) {
let n = 0, r = e.length;
for (let s = t.position.end.offset - 1; s < r; s++) {
let i = e[s];
if (i === `
` && n++, n === 1 && /\S/u.test(i)) return !1;
if (n === 2) return !0;
}
return !1;
}
function Ct(t) {
let { node: e } = t;
switch (e.type) {
case "tag":
case "anchor":
case "comment":
return !1;
}
let n = t.stack.length;
for (let r = 1; r < n; r++) {
let s = t.stack[r], i = t.stack[r - 1];
if (Array.isArray(i) && typeof s == "number" && s !== i.length - 1) return !1;
}
return !0;
}
function Mt(t) {
return ve(t.children) ? Mt(D(0, t.children, -1)) : t;
}
function Ir(t) {
return t.value.trim() === "prettier-ignore";
}
function xr(t) {
let { node: e } = t;
if (e.type === "documentBody") {
let n = t.parent.head;
return I(n) && Ir(D(0, n.endComments, -1));
}
return te(e) && Ir(D(0, e.leadingComments, -1));
}
function _e(t) {
return !ve(t.children) && !zi(t);
}
function zi(t) {
return te(t) || ae(t) || gn(t) || K(t) || I(t);
}
function te(t) {
return ve(t?.leadingComments);
}
function ae(t) {
return ve(t?.middleComments);
}
function gn(t) {
return t?.indicatorComment;
}
function K(t) {
return t?.trailingComment;
}
function I(t) {
return ve(t?.endComments);
}
function Rr(t) {
return t ? t.split(/(?<!^| ) (?! |$)/u) : [];
}
function Dr(t, e, n) {
let r = e.split(`
`).map((i, o, a) => o === 0 && o === a.length - 1 ? i : o !== 0 && o !== a.length - 1 ? i.trim() : o === 0 ? i.trimEnd() : i.trimStart());
if (n.proseWrap === "preserve") return r.map((i) => i ? [i] : []);
let s = [];
for (let [i, o] of r.entries()) {
let a = Rr(o);
i > 0 && r[i - 1].length > 0 && a.length > 0 && !(t === "quoteDouble" && D(0, D(0, s, -1), -1).endsWith("\\")) ? s[s.length - 1] = [...D(0, s, -1), ...a] : s.push(a);
}
return n.proseWrap === "never" ? s.map((i) => [i.join(" ")]) : s;
}
function $r(t, { parentIndent: e, isLastDescendant: n, options: r }) {
let s = t.position.start.line === t.position.end.line ? "" : r.originalText.slice(t.position.start.offset, t.position.end.offset).match(/^[^\n]*\n(.*)$/su)[1], i;
if (t.indent === null) {
let l = s.match(/^(?<leadingSpace> *)[^\n\r ]/mu);
i = l ? l.groups.leadingSpace.length : Number.POSITIVE_INFINITY;
} else i = t.indent - 1 + e;
let o = s.split(`
`).map((l) => l.slice(i));
if (r.proseWrap === "preserve" || t.type === "blockLiteral") return c(o.map((l) => l ? [l] : []));
let a = [];
for (let [l, f] of o.entries()) {
let m = Rr(f);
l > 0 && m.length > 0 && o[l - 1].length > 0 && !/^\s/u.test(m[0]) && !/^\s|\s$/u.test(D(0, a, -1)) ? a[a.length - 1] = [...D(0, a, -1), ...m] : a.push(m);
}
return a = a.map((l) => {
let f = [];
for (let m of l) f.length > 0 && /\s$/u.test(D(0, f, -1)) ? f[f.length - 1] += " " + m : f.push(m);
return f;
}), r.proseWrap === "never" && (a = a.map((l) => [l.join(" ")])), c(a);
function c(l) {
if (t.chomping === "keep") return D(0, l, -1).length === 0 ? l.slice(0, -1) : l;
let f = 0;
for (let m = l.length - 1; m >= 0 && l[m].length === 0; m--) f++;
return f === 0 ? l : f >= 2 && !n ? l.slice(0, -(f - 1)) : l.slice(0, -f);
}
}
function nt(t) {
if (!t) return !0;
switch (t.type) {
case "plain":
case "quoteDouble":
case "quoteSingle":
case "alias":
case "flowMapping":
case "flowSequence":
return !0;
default:
return !1;
}
}
function kt(t, e) {
let { node: n, root: r } = t, s;
return yn.has(r) ? s = yn.get(r) : (s = /* @__PURE__ */ new Set(), yn.set(r, s)), !s.has(n.position.end.line) && (s.add(n.position.end.line), _r(n, e) && !En(t.parent)) ? Lt : "";
}
function En(t) {
return I(t) && !W(t, ["documentHead", "documentBody", "flowMapping", "flowSequence"]);
}
function _(t, e) {
return Je(" ".repeat(t), e);
}
function Zi(t, e, n) {
let { node: r } = t, s = t.ancestors.filter((l) => l.type === "sequence" || l.type === "mapping").length, i = Ct(t), o = [r.type === "blockFolded" ? ">" : "|"];
r.indent !== null && o.push(r.indent.toString()), r.chomping !== "clip" && o.push(r.chomping === "keep" ? "+" : "-"), gn(r) && o.push(" ", n("indicatorComment"));
let a = $r(r, { parentIndent: s, isLastDescendant: i, options: e }), c = [];
for (let [l, f] of a.entries()) l === 0 && c.push(N), c.push(At(v(se, f))), l !== a.length - 1 ? c.push(f.length === 0 ? N : ur(He)) : r.chomping === "keep" && i && c.push(cn(f.length === 0 ? N : He));
return r.indent === null ? o.push(pr(_(e.tabWidth, c))) : o.push(cn(_(r.indent - 1 + s, c))), o;
}
function Pt(t, e, n) {
let { node: r } = t, s = r.type === "flowMapping", i = s ? "{" : "[", o = s ? "}" : "]", a = Lt;
s && r.children.length > 0 && e.bracketSpacing && (a = se);
let c = D(0, r.children, -1), l = c?.type === "flowMappingItem" && _e(c.key) && _e(c.value);
return [i, _(e.tabWidth, [a, eo(t, e, n), e.trailingComma === "none" ? "" : ze(","), I(r) ? [N, v(N, t.map(n, "endComments"))] : ""]), l ? "" : a, o];
}
function eo(t, e, n) {
return t.map(({ isLast: r, node: s, next: i }) => [n(), r ? "" : [",", se, s.position.start.line !== i.position.start.line ? kt(t, e.originalText) : ""]], "children");
}
function to(t, e, n) {
let { node: r, parent: s } = t, { key: i, value: o } = r, a = _e(i), c = _e(o);
if (a && c) return ": ";
let l = n("key"), f = no(r) ? " " : "";
if (c) return r.type === "flowMappingItem" && s.type === "flowMapping" ? l : r.type === "mappingItem" && Sn(i.content, e) && !K(i.content) && s.tag?.value !== "tag:yaml.org,2002:set" ? [l, f, ":"] : ["? ", _(2, l)];
let m = n("value");
if (a) return [": ", _(2, m)];
if (te(o) || !nt(i.content)) return ["? ", _(2, l), N, ...t.map(() => [n(), N], "value", "leadingComments"), ": ", _(2, m)];
if (ro(i.content) && !te(i.content) && !ae(i.content) && !K(i.content) && !I(i) && !te(o.content) && !ae(o.content) && !I(o) && Sn(o.content, e)) return [l, f, ": ", m];
let g = /* @__PURE__ */ Symbol("mappingKey"), y = Pe([ze("? "), Pe(_(2, l), { id: g })]), h = [N, ": ", _(2, m)], d = [f, ":"];
I(o) && o.content && W(o.content, ["flowMapping", "flowSequence"]) && o.content.children.length === 0 ? d.push(" ") : te(o.content) || I(o) && o.content && !W(o.content, ["mapping", "sequence"]) || s.type === "mapping" && K(i.content) && nt(o.content) || W(o.content, ["mapping", "sequence"]) && o.content.tag === null && o.content.anchor === null ? d.push(N) : o.content ? d.push(se) : K(o) && d.push(" "), d.push(m);
let w = _(e.tabWidth, d);
return Sn(i.content, e) && !te(i.content) && !ae(i.content) && !K(i.content) && !I(i) ? ln([[l, w]]) : ln([[y, ze(h, w, { groupId: g })]]);
}
function Sn(t, e) {
if (!t) return !0;
switch (t.type) {
case "plain":
case "quoteSingle":
case "quoteDouble":
break;
case "alias":
return !0;
default:
return !1;
}
if (e.proseWrap === "preserve") return t.position.start.line === t.position.end.line;
if (/\\$/mu.test(e.originalText.slice(t.position.start.offset, t.position.end.offset))) return !1;
switch (e.proseWrap) {
case "never":
return !t.value.includes(`
`);
case "always":
return !/[\n ]/u.test(t.value);
default:
return !1;
}
}
function no(t) {
return t.key.content?.type === "alias";
}
function ro(t) {
if (!t) return !0;
switch (t.type) {
case "plain":
case "quoteDouble":
case "quoteSingle":
return t.position.start.line === t.position.end.line;
case "alias":
return !0;
default:
return !1;
}
}
function so(t) {
return dn(t, io);
}
function io(t) {
switch (t.type) {
case "document":
Ie(t, "head", () => t.children[0]), Ie(t, "body", () => t.children[1]);
break;
case "documentBody":
case "sequenceItem":
case "flowSequenceItem":
case "mappingKey":
case "mappingValue":
Ie(t, "content", () => t.children[0]);
break;
case "mappingItem":
case "flowMappingItem":
Ie(t, "key", () => t.children[0]), Ie(t, "value", () => t.children[1]);
break;
}
return t;
}
function oo(t, e, n) {
let { node: r } = t, s = [];
r.type !== "mappingValue" && te(r) && s.push([v(N, t.map(n, "leadingComments")), N]);
let { tag: i, anchor: o } = r;
i && s.push(n("tag")), i && o && s.push(" "), o && s.push(n("anchor"));
let a = "";
return W(r, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !Ct(t) && (a = kt(t, e.originalText)), (i || o) && (W(r, ["sequence", "mapping"]) && !ae(r) ? s.push(N) : s.push(" ")), ae(r) && s.push([r.middleComments.length === 1 ? "" : N, v(N, t.map(n, "middleComments")), N]), xr(t) ? s.push(cr(e.originalText.slice(r.position.start.offset, r.position.end.offset).trimEnd())) : s.push(Pe(ao(t, e, n))), K(r) && !W(r, ["document", "documentHead"]) && s.push(mr([r.type === "mappingValue" && !r.content ? "" : " ", t.parent.type === "mappingKey" && t.getParentNode(2).type === "mapping" && nt(r) ? "" : Xe, n("trailingComment")])), En(r) && s.push(_(r.type === "sequenceItem" ? 2 : 0, [N, v(N, t.map(({ node: c }) => [pn(e.originalText, tt(c)) ? N : "", n()], "endComments"))])), s.push(a), s;
}
function ao(t, e, n) {
let { node: r } = t;
switch (r.type) {
case "root": {
let s = Mt(r), i = !(W(s, ["blockLiteral", "blockFolded"]) && s.chomping === "keep"), o = [];
return t.each(({ node: a, isFirst: c }) => {
c || o.push(N), o.push(n()), lo(t) && (i && o.push(N), o.push("..."), K(a) && o.push(" ", n("trailingComment")));
}, "children"), i && o.push(N), o;
}
case "document": {
let s = [];
return fo(t) && ((r.head.children.length > 0 || r.head.endComments.length > 0) && s.push(n("head")), K(r.head) ? s.push(["---", " ", n(["head", "trailingComment"])]) : s.push("---")), co(r) && s.push(n("body")), v(N, s);
}
case "documentHead":
return v(N, [...t.map(n, "children"), ...t.map(n, "endComments")]);
case "documentBody": {
let { children: s, endComments: i } = r, o = "";
if (s.length > 0 && i.length > 0) {
let a = Mt(r);
if (W(a, ["blockFolded", "blockLiteral"])) a.chomping !== "keep" && (o = [N, N]);
else {
let c = D(0, s, -1);
o = W(c, ["mapping"]) && pn(e.originalText, tt(i[0])) ? [N, N] : N;
}
}
return [v(N, t.map(n, "children")), o, v(N, t.map(n, "endComments"))];
}
case "directive":
return ["%", v(" ", [r.name, ...r.parameters])];
case "comment":
return ["#", r.value];
case "alias":
return ["*", r.value];
case "tag":
return e.originalText.slice(r.position.start.offset, r.position.end.offset);
case "anchor":
return ["&", r.value];
case "plain":
return rt(r.type, e.originalText.slice(r.position.start.offset, r.position.end.offset), e);
case "quoteDouble":
case "quoteSingle": {
let o = e.originalText.slice(r.position.start.offset + 1, r.position.end.offset - 1);
if (r.type === "quoteSingle" && o.includes("\\") || r.type === "quoteDouble" && /\\[^"]/u.test(o)) {
let c = r.type === "quoteDouble" ? '"' : "'";
return [c, rt(r.type, o, e), c];
}
if (o.includes('"')) return ["'", rt(r.type, r.type === "quoteDouble" ? ht(0, ht(0, o, '\\"', '"'), "'", "'".repeat(2)) : o, e), "'"];
if (o.includes("'")) return ['"', rt(r.type, r.type === "quoteSingle" ? ht(0, o, "''", "'") : o, e), '"'];
let a = e.singleQuote ? "'" : '"';
return [a, rt(r.type, o, e), a];
}
case "blockFolded":
case "blockLiteral":
return Yr(t, e, n);
case "mapping":
case "sequence":
return v(N, t.map(n, "children"));
case "sequenceItem":
return ["- ", _(2, r.content ? n("content") : "")];
case "mappingKey":
case "mappingValue":
return r.content ? n("content") : "";
case "mappingItem":
case "flowMappingItem":
return Br(t, e, n);
case "flowMapping":
return Pt(t, e, n);
case "flowSequence":
return Pt(t, e, n);
case "flowSequenceItem":
return n("content");
default:
throw new dr(r, "YAML");
}
}
function co(t) {
return t.body.children.length > 0 || I(t.body);
}
function lo(t) {
let e = t.node;
if (e.documentEndMarker || K(e)) return !0;
if (t.isLast) return !1;
let n = t.next;
return n.head.children.length > 0 || I(n.head);
}
function fo(t) {
let e = t.node;
return e.directivesEndMarker || e.head.children.length > 0 || I(e.head) || K(e.head);
}
function rt(t, e, n) {
let r = Dr(t, e, n);
return v(N, r.map((s) => At(v(se, s))));
}
function F(t, e = null) {
"children" in t && t.children.forEach((n) => F(n, t)), "anchor" in t && t.anchor && F(t.anchor, t), "tag" in t && t.tag && F(t.tag, t), "leadingComments" in t && t.leadingComments.forEach((n) => F(n, t)), "middleComments" in t && t.middleComments.forEach((n) => F(n, t)), "indicatorComment" in t && t.indicatorComment && F(t.indicatorComment, t), "trailingComment" in t && t.trailingComment && F(t.trailingComment, t), "endComments" in t && t.endComments.forEach((n) => F(n, t)), Object.defineProperty(t, "_parent", { value: e, enumerable: !1 });
}
function Oe(t) {
return `${t.line}:${t.column}`;
}
function Is(t) {
F(t);
let e = _a(t), n = t.children.slice();
t.comments.sort((r, s) => r.position.start.offset - s.position.end.offset).filter((r) => !r._parent).forEach((r) => {
for (; n.length > 1 && r.position.start.line > n[0].position.end.line; ) n.shift();
xa(r, e, n[0]);
});
}
function _a(t) {
let e = Array.from(new Array(t.position.end.line), () => ({}));
for (let n of t.comments) e[n.position.start.line - 1].comment = n;
return _s(e, t), e;
}
function _s(t, e) {
if (e.position.start.offset !== e.position.end.offset) {
if ("leadingComments" in e) {
let { start: n } = e.position, { leadingAttachableNode: r } = t[n.line - 1];
(!r || n.column < r.position.start.column) && (t[n.line - 1].leadingAttachableNode = e);
}
if ("trailingComment" in e && e.position.end.column > 1 && e.type !== "document" && e.type !== "documentHead") {
let { end: n } = e.position, { trailingAttachableNode: r } = t[n.line - 1];
(!r || n.column >= r.position.end.column) && (t[n.line - 1].trailingAttachableNode = e);
}
if (e.type !== "root" && e.type !== "document" && e.type !== "documentHead" && e.type !== "documentBody") {
let { start: n, end: r } = e.position, s = [r.line].concat(n.line === r.line ? [] : n.line);
for (let i of s) {
let o = t[i - 1].trailingNode;
(!o || r.column >= o.position.end.column) && (t[i - 1].trailingNode = e);
}
}
"children" in e && e.children.forEach((n) => {
_s(t, n);
});
}
}
function xa(t, e, n) {
let r = t.position.start.line, { trailingAttachableNode: s } = e[r - 1];
if (s) {
if (s.trailingComment) throw new Error(`Unexpected multiple trailing comment at ${Oe(t.position.start)}`);
F(t, s), s.trailingComment = t;
return;
}
for (let o = r; o >= n.position.start.line; o--) {
let { trailingNode: a } = e[o - 1], c;
if (a) c = a;
else if (o !== r && e[o - 1].comment) c = e[o - 1].comment._parent;
else continue;
if ((c.type === "sequence" || c.type === "mapping") && (c = c.children[0]), c.type === "mappingItem") {
let [l, f] = c.children;
c = xs(l) ? l : f;
}
for (; ; ) {
if (Ra(c, t)) {
F(t, c), c.endComments.push(t);
return;
}
if (!c._parent) break;
c = c._parent;
}
break;
}
for (let o = r + 1; o <= n.position.end.line; o++) {
let { leadingAttachableNode: a } = e[o - 1];
if (a) {
F(t, a), a.leadingComments.push(t);
return;
}
}
let i = n.children[1];
F(t, i), i.endComments.push(t);
}
function Ra(t, e) {
if (t.position.start.offset < e.position.start.offset && t.position.end.offset > e.position.end.offset) switch (t.type) {
case "flowMapping":
case "flowSequence":
return t.children.length === 0 || e.position.start.line > t.children[t.children.length - 1].position.end.line;
}
if (e.position.end.offset < t.position.end.offset) return !1;
switch (t.type) {
case "sequenceItem":
return e.position.start.column > t.position.start.column;
case "mappingKey":
case "mappingValue":
return e.position.start.column > t._parent.position.start.column && (t.children.length === 0 || t.children.length === 1 && t.children[0].type !== "blockFolded" && t.children[0].type !== "blockLiteral") && (t.type === "mappingValue" || xs(t));
default:
return !1;
}
}
function xs(t) {
return t.position.start !== t.position.end && (t.children.length === 0 || t.position.start.offset !== t.children[0].position.start.offset);
}
function b(t, e) {
return { type: t, position: e };
}
function Rs(t, e, n) {
return { ...b("root", t), children: e, comments: n };
}
function pt(t) {
switch (t.type) {
case "DOCUMENT":
for (let e = t.contents.length - 1; e >= 0; e--) t.contents[e].type === "BLANK_LINE" ? t.contents.splice(e, 1) : pt(t.contents[e]);
for (let e = t.directives.length - 1; e >= 0; e--) t.directives[e].type === "BLANK_LINE" && t.directives.splice(e, 1);
break;
case "FLOW_MAP":
case "FLOW_SEQ":
case "MAP":
case "SEQ":
for (let e = t.items.length - 1; e >= 0; e--) {
let n = t.items[e];
"char" in n || (n.type === "BLANK_LINE" ? t.items.splice(e, 1) : pt(n));
}
break;
case "MAP_KEY":
case "MAP_VALUE":
case "SEQ_ITEM":
t.node && pt(t.node);
break;
case "ALIAS":
case "BLANK_LINE":
case "BLOCK_FOLDED":
case "BLOCK_LITERAL":
case "COMMENT":
case "DIRECTIVE":
case "PLAIN":
case "QUOTE_DOUBLE":
case "QUOTE_SINGLE":
break;
default:
throw new Error(`Unexpected node type ${JSON.stringify(t.type)}`);
}
}
function X(t, e) {
return { start: t, end: e };
}
function Hn(t) {
return { start: t, end: t };
}
function Ds(t, e) {
return { ...b("anchor", t), value: e };
}
function Ve(t, e) {
return { ...b("comment", t), value: e };
}
function $s(t, e, n) {
return { anchor: e, tag: t, middleComments: n };
}
function Ys(t, e) {
return { ...b("tag", t), value: e };
}
function Ht(t, e, n = () => !1) {
let r = t.cstNode, s = [], i = null, o = null, a = null;
for (let c of r.props) {
let l = e.text[c.origStart];
switch (l) {
case me.Tag:
i = i || c, o = Ys(e.transformRange(c), t.tag);
break;
case me.Anchor:
i = i || c, a = Ds(e.transformRange(c), r.anchor);
break;
case me.Comment: {
let f = Ve(e.transformRange(c), e.text.slice(c.origStart + 1, c.origEnd));
e.comments.push(f), !n(f) && i && i.origEnd <= c.origStart && c.origEnd <= r.valueRange.origStart && s.push(f);
break;
}
default:
throw new Error(`Unexpected leading character ${JSON.stringify(l)}`);
}
}
return $s(o, a, s);
}
function z() {
return { leadingComments: [] };
}
function he(t = null) {
return { trailingComment: t };
}
function q() {
return { ...z(), ...he() };
}
function Bs(t, e, n) {
return { ...b("alias", t), ...q(), ...e, value: n };
}
function Fs(t, e) {
let n = t.cstNode;
return Bs(e.transformRange({ origStart: n.valueRange.origStart - 1, origEnd: n.valueRange.origEnd }), e.transformContent(t), n.rawValue);
}
function qs(t) {
return { ...t, type: "blockFolded" };
}
function Us(t, e, n, r, s, i) {
return { ...b("blockValue", t), ...z(), ...e, chomping: n, indent: r, value: s, indicatorComment: i };
}
function Jt(t, e) {
let n = t.cstNode, r = 1, s = n.chomping === "CLIP" ? 0 : 1, o = n.header.origEnd - n.header.origStart - r - s !== 0, a = e.transformRange({ origStart: n.header.origStart, origEnd: n.valueRange.origEnd }), c = null, l = Ht(t, e, (f) => {
if (!(a.start.offset < f.position.start.offset && f.position.end.offset < a.end.offset)) return !1;
if (c) throw new Error(`Unexpected multiple indicator comments at ${Oe(f.position.start)}`);
return c = f, !0;
});
return Us(a, l, Jn[n.chomping], o ? n.blockIndent : null, n.strValue, c);
}
function Vs(t, e) {
return qs(Jt(t, e));
}
function Ws(t) {
return { ...t, type: "blockLiteral" };
}
function Ks(t, e) {
return Ws(Jt(t, e));
}
function js(t, e) {
return Ve(e.transformRange(t.range), t.comment);
}
function Qs(t, e, n) {
return { ...b("directive", t), ...q(), name: e, parameters: n };
}
function We(t, e) {
for (let n of t.props) {
let r = e.text[n.origStart];
if (r === me.Comment)
e.comments.push(Ve(e.transformRange(n), e.text.slice(n.origStart + 1, n.origEnd)));
else
throw new Error(`Unexpected leading character ${JSON.stringify(r)}`);
}
}
function Gs(t, e) {
return We(t, e), Qs(e.transformRange(t.range), t.name, t.parameters);
}
function Hs(t, e, n, r, s, i) {
return { ...b("document", t), ...he(i), directivesEndMarker: e, documentEndMarker: n, children: [r, s] };
}
function U(t = []) {
return { endComments: t };
}
function Js(t, e, n) {
return { ...b("documentBody", t), ...U(n), children: e ? [e] : [] };
}
function V(t) {
return t[t.length - 1];
}
function Xt(t, e) {
let n = t.match(e);
return n ? n.index : -1;
}
function Xs(t, e, n) {
let r = t.cstNode, { comments: s, endComments: i, documentTrailingComment: o, documentHeadTrailingComment: a } = Da(r, e, n), c = e.transformNode(t.contents), { position: l, documentEndPoint: f } = $a(r, c, e);
return e.comments.push(...s, ...i), { documentBody: Js(l, c, i), documentEndPoint: f, documentTrailingComment: o, documentHeadTrailingComment: a };
}
function Da(t, e, n) {
let r = [], s = [], i = [], o = [], a = !1;
for (let c = t.contents.length - 1; c >= 0; c--) {
let l = t.contents[c];
if (l.type === "COMMENT") {
let f = e.transformNode(l);
n && n.line === f.position.start.line ? o.unshift(f) : a ? r.unshift(f) : f.position.start.offset >= t.valueRange.origEnd ? i.unshift(f) : r.unshift(f);
} else a = !0;
}
if (i.length > 1) throw new Error(`Unexpected multiple document trailing comments at ${Oe(i[1].position.start)}`);
if (o.length > 1) throw new Error(`Unexpected multiple documentHead trailing comments at ${Oe(o[1].position.start)}`);
return { comments: r, endComments: s, documentTrailingComment: V(i) || null, documentHeadTrailingComment: V(o) || null };
}
function $a(t, e, n) {
let r = Xt(n.text.slice(t.valueRange.origEnd), /^\.\.\./), s = r === -1 ? t.valueRange.origEnd : Math.max(0, t.valueRange.origEnd - 1);
n.text[s - 1] === "\r" && s--;
let i = n.transformRange({ origStart: e !== null ? e.position.start.offset : s, origEnd: s }), o = r === -1 ? i.end : n.transformOffset(t.valueRange.origEnd + 3);
return { position: i, documentEndPoint: o };
}
function zs(t, e, n, r) {
return { ...b("documentHead", t), ...U(n), ...he(r), children: e };
}
function Zs(t, e) {
let n = t.cstNode, { directives: r, comments: s, endComments: i } = Ya(n, e), { position: o, documentEndMarkererPoint: a } = Ba(n, r, e);
return e.comments.push(...s, ...i), { createDocumentHeadWithTrailingComment: (l) => (l && e.comments.push(l), zs(o, r, i, l)), documentHeadEndMarkerPoint: a };
}
function Ya(t, e) {
let n = [], r = [], s = [], i = !1;
for (let o = t.directives.length - 1; o >= 0; o--) {
let a = e.transformNode(t.directives[o]);
a.type === "comment" ? i ? r.unshift(a) : s.unshift(a) : (i = !0, n.unshift(a));
}
return { directives: n, comments: r, endComments: s };
}
function Ba(t, e, n) {
let r = Xt(n.text.slice(0, t.valueRange.origStart), /---\s*$/);
r > 0 && !/[\r\n]/.test(n.text[r - 1]) && (r = -1);
let s = r === -1 ? { origStart: t.valueRange.origStart, origEnd: t.valueRange.origStart } : { origStart: r, origEnd: r + 3 };
return e.length !== 0 && (s.origStart = e[0].position.start.offset), { position: n.transformRange(s), documentEndMarkererPoint: r === -1 ? null : n.transformOffset(r) };
}
function ei(t, e) {
let { createDocumentHeadWithTrailingComment: n, documentHeadEndMarkerPoint: r } = Zs(t, e), { documentBody: s, documentEndPoint: i, documentTrailingComment: o, documentHeadTrailingComment: a } = Xs(t, e, r), c = n(a);
o && e.comments.push(o);
let l = t.cstNode;
return Hs(X(c.position.start, i), !!l.directivesEndMarker, !!l.documentEndMarker, c, s, o);
}
function zt(t, e, n) {
return { ...b("flowCollection", t), ...q(), ...U(), ...e, children: n };
}
function ti(t, e, n) {
return { ...zt(t, e, n), type: "flowMapping" };
}
function Zt(t, e, n) {
return { ...b("flowMappingItem", t), ...z(), children: [e, n] };
}
function de(t, e) {
let n = [];
for (let r of t) r && "type" in r && r.type === "COMMENT" ? e.comments.push(e.transformNode(r)) : n.push(r);
return n;
}
function en(t) {
let [e, n] = ["?", ":"].map((r) => {
let s = t.find((i) => "char" in i && i.char === r);
return s ? { origStart: s.origOffset, origEnd: s.origOffset + 1 } : null;
});
return { additionalKeyRange: e, additionalValueRange: n };
}
function tn(t, e) {
let n = e;
return (r) => t.slice(n, n = r);
}
function nn(t) {
let e = [], n = tn(t, 1), r = !1;
for (let s = 1; s < t.length - 1; s++) {
let i = t[s];
if ("char" in i && i.char === ",") {
e.push(n(s)), n(s + 1), r = !1;
continue;
}
r = !0;
}
return r && e.push(n(t.length - 1)), e;
}
function Xn(t, e) {
return { ...b("mappingKey", t), ...he(), ...U(), children: e ? [e] : [] };
}
function zn(t, e) {
return { ...b("mappingValue", t), ...q(), ...U(), children: e ? [e] : [] };
}
function Ke(t, e, n, r, s) {
let i = e.transformNode(t.key), o = e.transformNode(t.value), a = i || r ? Xn(e.transformRange({ origStart: r ? r.origStart : i.position.start.offset, origEnd: i ? i.position.end.offset : r.origStart + 1 }), i) : null, c = o || s ? zn(e.transformRange({ origStart: s ? s.origStart : o.position.start.offset, origEnd: o ? o.position.end.offset : s.origStart + 1 }), o) : null;
return n(X(a ? a.position.start : c.position.start, c ? c.position.end : a.position.end), a || Xn(Hn(c.position.start), null), c || zn(Hn(a.position.end), null));
}
function ni(t, e) {
let n = de(t.cstNode.items, e), r = nn(n), s = t.items.map((a, c) => {
let l = r[c], { additionalKeyRange: f, additionalValueRange: m } = en(l);
return Ke(a, e, Zt, f, m);
}), i = n[0], o = V(n);
return ti(e.transformRange({ origStart: i.origOffset, origEnd: o.origOffset + 1 }), e.transformContent(t), s);
}
function ri(t, e, n) {
return { ...zt(t, e, n), type: "flowSequence" };
}
function si(t, e) {
return { ...b("flowSequenceItem", t), children: [e] };
}
function ii(t, e) {
let n = de(t.cstNode.items, e), r = nn(n), s = t.items.map((a, c) => {
if (a.type !== "PAIR") {
let l = e.transformNode(a);
return si(X(l.position.start, l.position.end), l);
} else {
let l = r[c], { additionalKeyRange: f, additionalValueRange: m } = en(l);
return Ke(a, e, Zt, f, m);
}
}), i = n[0], o = V(n);
return ri(e.transformRange({ origStart: i.origOffset, origEnd: o.origOffset + 1 }), e.transformContent(t), s);
}
function oi(t, e, n) {
return { ...b("mapping", t), ...z(), ...e, children: n };
}
function ai(t, e, n) {
return { ...b("mappingItem", t), ...z(), children: [e, n] };
}
function ci(t, e) {
let n = t.cstNode;
n.items.filter((o) => o.type === "MAP_KEY" || o.type === "MAP_VALUE").forEach((o) => We(o, e));
let r = de(n.items, e), s = Fa(r), i = t.items.map((o, a) => {
let c = s[a], [l, f] = c[0].type === "MAP_VALUE" ? [null, c[0].range] : [c[0].range, c.length === 1 ? null : c[1].range];
return Ke(o, e, ai, l, f);
});
return oi(X(i[0].position.start, V(i).position.end), e.transformContent(t), i);
}
function Fa(t) {
let e = [], n = tn(t, 0), r = !1;
for (let s = 0; s < t.length; s++) {
if (t[s].type === "MAP_VALUE") {
e.push(n(s + 1)), r = !1;
continue;
}
r && e.push(n(s)), r = !0;
}
return r && e.push(n(1 / 0)), e;
}
function li(t, e, n) {
return { ...b("plain", t), ...q(), ...e, value: n };
}
function fi(t, e, n) {
for (let r = e; r >= 0; r--) if (n.test(t[r])) return r;
return -1;
}
function ui(t, e) {
let n = t.cstNode;
return li(e.transformRange({ origStart: n.valueRange.origStart, origEnd: fi(e.text, n.valueRange.origEnd - 1, /\S/) + 1 }), e.transformContent(t), n.strValue);
}
function pi(t) {
return { ...t, type: "quoteDouble" };
}
function mi(t, e, n) {
return { ...b("quoteValue", t), ...e, ...q(), value: n };
}
function rn(t, e) {
let n = t.cstNode;
return mi(e.transformRange(n.valueRange), e.transformContent(t), n.strValue);
}
function hi(t, e) {
return pi(rn(t, e));
}
function di(t) {
return { ...t, type: "quoteSingle" };
}
function gi(t, e) {
return di(rn(t, e));
}
function yi(t, e, n) {
return { ...b("sequence", t), ...z(), ...U(), ...e, children: n };
}
function Ei(t, e) {
return { ...b("sequenceItem", t), ...q(), ...U(), children: e ? [e] : [] };
}
function Si(t, e) {
let r = de(t.cstNode.items, e).map((s, i) => {
We(s, e);
let o = e.transformNode(t.items[i]);
return Ei(X(e.transformOffset(s.valueRange.origStart), o === null ? e.transformOffset(s.valueRange.origStart + 1) : o.position.end), o);
});
return yi(X(r[0].position.start, V(r).position.end), e.transformContent(t), r);
}
function wi(t, e) {
if (t === null || t.type === void 0 && t.value === null) return null;
switch (t.type) {
case "ALIAS":
return Fs(t, e);
case "BLOCK_FOLDED":
return Vs(t, e);
case "BLOCK_LITERAL":
return Ks(t, e);
case "COMMENT":
return js(t, e);
case "DIRECTIVE":
return Gs(t, e);
case "DOCUMENT":
return ei(t, e);
case "FLOW_MAP":
return ni(t, e);
case "FLOW_SEQ":
return ii(t, e);
case "MAP":
return ci(t, e);
case "PLAIN":
return ui(t, e);
case "QUOTE_DOUBLE":
return hi(t, e);
case "QUOTE_SINGLE":
return gi(t, e);
case "SEQ":
return Si(t, e);
default:
throw new Error(`Unexpected node type ${t.type}`);
}
}
function Ni(t, e, n) {
let r = new SyntaxError(t);
return r.name = "YAMLSyntaxError", r.source = e, r.position = n, r;
}
function Oi(t, e) {
let n = t.source.range || t.source.valueRange;
return Ni(t.message, e.text, e.transformRange(n));
}
function tr(t) {
if ("children" in t) {
if (t.children.length === 1) {
let e = t.children[0];
if (e.type === "plain" && e.tag === null && e.anchor === null && e.value === "") return t.children.splice(0, 1), t;
}
t.children.forEach(tr);
}
return t;
}
function nr(t, e, n, r) {
let s = e(t);
return (i) => {
r(s, i) && n(t, s = i);
};
}
function rr(t) {
if (t === null || !("children" in t)) return;
let e = t.children;
if (e.forEach(rr), t.type === "document") {
let [i, o] = t.children;
i.position.start.offset === i.position.end.offset ? i.position.start = i.position.end = o.position.start : o.position.start.offset === o.position.end.offset && (o.position.start = o.position.end = i.position.end);
}
let n = nr(t.position, qa, Ua, Ka), r = nr(t.position, Va, Wa, ja);
"endComments" in t && t.endComments.length !== 0 && (n(t.endComments[0].position.start), r(V(t.endComments).position.end));
let s = e.filter((i) => i !== null);
if (s.length !== 0) {
let i = s[0], o = V(s);
n(i.position.start), r(o.position.end), "leadingComments" in i && i.leadingComments.length !== 0 && n(i.leadingComments[0].position.start), "tag" in i && i.tag && n(i.tag.position.start), "anchor" in i && i.anchor && n(i.anchor.position.start), "trailingComment" in o && o.trailingComment && r(o.trailingComment.position.end);
}
}
function qa(t) {
return t.start;
}
function Ua(t, e) {
t.start = e;
}
function Va(t) {
return t.end;
}
function Wa(t, e) {
t.end = e;
}
function Ka(t, e) {
return e.offset < t.offset;
}
function ja(t, e) {
return e.offset > t.offset;
}
function Ai(t) {
let e = sr.default.parseCST(t), n = new bi(e, t);
n.setOrigRanges();
let r = e.map((i) => new sr.default.Document({ merge: !1, keepCstNodes: !0 }).parse(i));
for (let i of r) for (let o of i.errors) if (!(o instanceof vs && o.message === 'Map keys must be unique; "<<" is repeated')) throw Oi(o, n);
r.forEach((i) => pt(i.cstNode));
let s = Rs(n.transformRange({ origStart: 0, origEnd: t.length }), r.map((i) => n.transformNode(i)), n.comments);
return Is(s), rr(s), tr(s), s;
}
function Qa(t, e) {
let n = new SyntaxError(t + " (" + e.loc.start.line + ":" + e.loc.start.column + ")");
return Object.assign(n, e);
}
function Ga(t) {
try {
let e = Ai(t);
return delete e.comments, e;
} catch (e) {
throw e?.position ? Li(e.message, { loc: e.position, cause: e }) : e;
}
}
var ki, sn, Pi, vi, Ii, _i, ne, or, xi, on, ce, Qr, De, qn, Kn, Ls, Ms, Gn, Ps, Ci, mt, Di, D, $i, Yi, ht, Bi, je, Qe, Ge, dt, gt, Ae, yt, Le, Te, Ce, Et, Me, St, re, wt, ke, bt, Nt, qi, an, ar, Z, Ot, lr, fr, Xe, se, Lt, Wi, N, Ki, He, sl, fn, il, ol, hr, un, pn, mn, dr, gr, yr, Er, Sr, wr, br, Nr, Or, Lr, Cr, Ze, Gi, Mr, k, kr, Ji, Pr, tt, vr, ve, yn, Yr, Br, Fr, uo, qr, Ur, vt, po, Vr, ir, sr, J, Cf, Mf, kf, Pf, vf, If, _f, xf, Rf, vs, Df, $f, me, Jn, Zn, er, bi, Li, Ha, Ja, Ti, Xa, init_yaml = __esm({
"../../node_modules/.pnpm/prettier@3.7.4/node_modules/prettier/plugins/yaml.mjs"() {
init_cjs_shims();
ki = Object.create, sn = Object.defineProperty, Pi = Object.getOwnPropertyDescriptor, vi = Object.getOwnPropertyNames, Ii = Object.getPrototypeOf, _i = Object.prototype.hasOwnProperty, ne = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports), or = (t, e) => {
for (var n in e) sn(t, n, { get: e[n], enumerable: !0 });
}, xi = (t, e, n, r) => {
if (e && typeof e == "object" || typeof e == "function") for (let s of vi(e)) !_i.call(t, s) && s !== n && sn(t, s, { get: () => e[s], enumerable: !(r = Pi(e, s)) || r.enumerable });
return t;
}, on = (t, e, n) => (n = t != null ? ki(Ii(t)) : {}, xi(e || !t || !t.__esModule ? sn(n, "default", { value: t, enumerable: !0 }) : n, t)), ce = ne((B) => {
"use strict";
var ie = { ANCHOR: "&", COMMENT: "#", TAG: "!", DIRECTIVES_END: "-", DOCUMENT_END: "." }, st = { ALIAS: "ALIAS", BLANK_LINE: "BLANK_LINE", BLOCK_FOLDED: "BLOCK_FOLDED", BLOCK_LITERAL: "BLOCK_LITERAL", COMMENT: "COMMENT", DIRECTIVE: "DIRECTIVE", DOCUMENT: "DOCUMENT", FLOW_MAP: "FLOW_MAP", FLOW_SEQ: "FLOW_SEQ", MAP: "MAP", MAP_KEY: "MAP_KEY", MAP_VALUE: "MAP_VALUE", PLAIN: "PLAIN", QUOTE_DOUBLE: "QUOTE_DOUBLE", QUOTE_SINGLE: "QUOTE_SINGLE", SEQ: "SEQ", SEQ_ITEM: "SEQ_ITEM" }, mo = "tag:yaml.org,2002:", ho = { MAP: "tag:yaml.org,2002:map", SEQ: "tag:yaml.org,2002:seq", STR: "tag:yaml.org,2002:str" };
function Wr(t) {
let e = [0], n = t.indexOf(`
`);
for (; n !== -1; ) n += 1, e.push(n), n = t.indexOf(`
`, n);
return e;
}
function Kr(t) {
let e, n;
return typeof t == "string" ? (e = Wr(t), n = t) : (Array.isArray(t) && (t = t[0]), t && t.context && (t.lineStarts || (t.lineStarts = Wr(t.context.src)), e = t.lineStarts, n = t.context.src)), { lineStarts: e, src: n };
}
function wn(t, e) {
if (typeof t != "number" || t < 0) return null;
let { lineStarts: n, src: r } = Kr(e);
if (!n || !r || t > r.length) return null;
for (let i = 0; i < n.length; ++i) {
let o = n[i];
if (t < o) return { line: i, col: t - n[i - 1] + 1 };
if (t === o) return { line: i + 1, col: 1 };
}
let s = n.length;
return { line: s, col: t - n[s - 1] + 1 };
}
function go(t, e) {
let { lineStarts: n, src: r } = Kr(e);
if (!n || !(t >= 1) || t > n.length) return null;
let s = n[t - 1], i = n[t];
for (; i && i > s && r[i - 1] === `
`; ) --i;
return r.slice(s, i);
}
function yo({ start: t, end: e }, n, r = 80) {
let s = go(t.line, n);
if (!s) return null;
let { col: i } = t;
if (s.length > r) if (i <= r - 10) s = s.substr(0, r - 1) + "\u2026";
else {
let f = Math.round(r / 2);
s.length > i + f && (s = s.substr(0, i + f - 1) + "\u2026"), i -= s.length - r, s = "\u2026" + s.substr(1 - r);
}
let o = 1, a = "";
e && (e.line === t.line && i + (e.col - t.col) <= r + 1 ? o = e.col - t.col : (o = Math.min(s.length + 1, r) - i, a = "\u2026"));
let c = i > 1 ? " ".repeat(i - 1) : "", l = "^".repeat(o);
return `${s}
${c}${l}${a}`;
}
var xe = class t {
static copy(e) {
return new t(e.start, e.end);
}
constructor(e, n) {
this.start = e, this.end = n || e;
}
isEmpty() {
return typeof this.start != "number" || !this.end || this.end <= this.start;
}
setOrigRange(e, n) {
let { start: r, end: s } = this;
if (e.length === 0 || s <= e[0]) return this.origStart = r, this.origEnd = s, n;
let i = n;
for (; i < e.length && !(e[i] > r); ) ++i;
this.origStart = r + i;
let o = i;
for (; i < e.length && !(e[i] >= s); ) ++i;
return this.origEnd = s + i, o;
}
}, oe = class t {
static addStringTerminator(e, n, r) {
if (r[r.length - 1] === `
`) return r;
let s = t.endOfWhiteSpace(e, n);
return s >= e.length || e[s] === `
` ? r + `
` : r;
}
static atDocumentBoundary(e, n, r) {
let s = e[n];
if (!s) return !0;
let i = e[n - 1];
if (i && i !== `
`) return !1;
if (r) {
if (s !== r) return !1;
} else if (s !== ie.DIRECTIVES_END && s !== ie.DOCUMENT_END) return !1;
let o = e[n + 1], a = e[n + 2];
if (o !== s || a !== s) return !1;
let c = e[n + 3];
return !c || c === `
` || c === " " || c === " ";
}
static endOfIdentifier(e, n) {
let r = e[n], s = r === "<", i = s ? [`
`, " ", " ", ">"] : [`
`, " ", " ", "[", "]", "{", "}", ","];
for (; r && i.indexOf(r) === -1; ) r = e[n += 1];
return s && r === ">" && (n += 1), n;
}
static endOfIndent(e, n) {
let r = e[n];
for (; r === " "; ) r = e[n += 1];
return n;
}
static endOfLine(e, n) {
let r = e[n];
for (; r && r !== `
`; ) r = e[n += 1];
return n;
}
static endOfWhiteSpace(e, n) {
let r = e[n];
for (; r === " " || r === " "; ) r = e[n += 1];
return n;
}
static startOfLine(e, n) {
let r = e[n - 1];
if (r === `
`) return n;
for (; r && r !== `
`; ) r = e[n -= 1];
return n + 1;
}
static endOfBlockIndent(e, n, r) {
let s = t.endOfIndent(e, r);
if (s > r + n) return s;
{
let i = t.endOfWhiteSpace(e, s), o = e[i];
if (!o || o === `
`) return i;
}
return null;
}
static atBlank(e, n, r) {
let s = e[n];
return s === `
` || s === " " || s === " " || r && !s;
}
static nextNodeIsIndented(e, n, r) {
return !e || n < 0 ? !1 : n > 0 ? !0 : r && e === "-";
}
static normalizeOffset(e, n) {
let r = e[n];
return r ? r !== `
` && e[n - 1] === `
` ? n - 1 : t.endOfWhiteSpace(e, n) : n;
}
static foldNewline(e, n, r) {
let s = 0, i = !1, o = "", a = e[n + 1];
for (; a === " " || a === " " || a === `
`; ) {
switch (a) {
case `
`:
s = 0, n += 1, o += `
`;
break;
case " ":
s <= r && (i = !0), n = t.endOfWhiteSpace(e, n + 2) - 1;
break;
case " ":
s += 1, n += 1;
break;
}
a = e[n + 1];
}
return o || (o = " "), a && s <= r && (i = !0), { fold: o, offset: n, error: i };
}
constructor(e, n, r) {
Object.defineProperty(this, "context", { value: r || null, writable: !0 }), this.error = null, this.range = null, this.valueRange = null, this.props = n || [], this.type = e, this.value = null;
}
getPropValue(e, n, r) {
if (!this.context) return null;
let { src: s } = this.context, i = this.props[e];
return i && s[i.start] === n ? s.slice(i.start + (r ? 1 : 0), i.end) : null;
}
get anchor() {
for (let e = 0; e < this.props.length; ++e) {
let n = this.getPropValue(e, ie.ANCHOR, !0);
if (n != null) return n;
}
return null;
}
get comment() {
let e = [];
for (let n = 0; n < this.props.length; ++n) {
let r = this.getPropValue(n, ie.COMMENT, !0);
r != null && e.push(r);
}
return e.length > 0 ? e.join(`
`) : null;
}
commentHasRequiredWhitespace(e) {
let { src: n } = this.context;
if (this.header && e === this.header.end || !this.valueRange) return !1;
let { end: r } = this.valueRange;
return e !== r || t.atBlank(n, r - 1);
}
get hasComment() {
if (this.context) {
let { src: e } = this.context;
for (let n = 0; n < this.props.length; ++n) if (e[this.props[n].start] === ie.COMMENT) return !0;
}
return !1;
}
get hasProps() {
if (this.context) {
let { src: e } = this.context;
for (let n = 0; n < this.props.length; ++n) if (e[this.props[n].start] !== ie.COMMENT) return !0;
}
return !1;
}
get includesTrailingLines() {
return !1;
}
get jsonLike() {
return [st.FLOW_MAP, st.FLOW_SEQ, st.QUOTE_DOUBLE, st.QUOTE_SINGLE].indexOf(this.type) !== -1;
}
get rangeAsLinePos() {
if (!this.range || !this.context) return;
let e = wn(this.range.start, this.context.root);
if (!e) return;
let n = wn(this.range.end, this.context.root);
return { start: e, end: n };
}
get rawValue() {
if (!this.valueRange || !this.context) return null;
let { start: e, end: n } = this.valueRange;
return this.context.src.slice(e, n);
}
get tag() {
for (let e = 0; e < this.props.length; ++e) {
let n = this.getPropValue(e, ie.TAG, !1);
if (n != null) {
if (n[1] === "<") return { verbatim: n.slice(2, -1) };
{
let [r, s, i] = n.match(/^(.*!)([^!]*)$/);
return { handle: s, suffix: i };
}
}
}
return null;
}
get valueRangeContainsNewline() {
if (!this.valueRange || !this.context) return !1;
let { start: e, end: n } = this.valueRange, { src: r } = this.context;
for (let s = e; s < n; ++s) if (r[s] === `
`) return !0;
return !1;
}
parseComment(e) {
let { src: n } = this.context;
if (n[e] === ie.COMMENT) {
let r = t.endOfLine(n, e + 1), s = new xe(e, r);
return this.props.push(s), r;
}
return e;
}
setOrigRanges(e, n) {
return this.range && (n = this.range.setOrigRange(e, n)), this.valueRange && this.valueRange.setOrigRange(e, n), this.props.forEach((r) => r.setOrigRange(e, n)), n;
}
toString() {
let { context: { src: e }, range: n, value: r } = this;
if (r != null) return r;
let s = e.slice(n.start, n.end);
return t.addStringTerminator(e, n.end, s);
}
}, ge = class extends Error {
constructor(e, n, r) {
if (!r || !(n instanceof oe)) throw new Error(`Invalid arguments for new ${e}`);
super(), this.name = e, this.message = r, this.source = n;
}
makePretty() {
if (!this.source) return;
this.nodeType = this.source.type;
let e = this.source.context && this.source.context.root;
if (typeof this.offset == "number") {
this.range = new xe(this.offset, this.offset + 1);
let n = e && wn(this.offset, e);
if (n) {
let r = { line: n.line, col: n.col + 1 };
this.linePos = { start: n, end: r };
}
delete this.offset