prettier-plugin-pegjs
Version:
A Prettier plugin for formatting Pegjs and Peggy-js grammars
1,033 lines • 719 kB
JavaScript
var kh = Object.defineProperty;
var Nh = (e, r, s) => r in e ? kh(e, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[r] = s;
var Ht = (e, r, s) => (Nh(e, typeof r != "symbol" ? r + "" : r, s), s);
import { p as Ih } from "./prettier-plugin-pegjs-49f976fe.js";
var Lh = Object.create, Hs = Object.defineProperty, Mh = Object.getOwnPropertyDescriptor, Oh = Object.getOwnPropertyNames, jh = Object.getPrototypeOf, $h = Object.prototype.hasOwnProperty, _h = (e, r) => () => (e && (r = e(e = 0)), r), Ks = (e, r) => () => (r || e((r = { exports: {} }).exports, r), r.exports), Xs = (e, r) => {
for (var s in r)
Hs(e, s, { get: r[s], enumerable: !0 });
}, Vo = (e, r, s, a) => {
if (r && typeof r == "object" || typeof r == "function")
for (let u of Oh(r))
!$h.call(e, u) && u !== s && Hs(e, u, { get: () => r[u], enumerable: !(a = Mh(r, u)) || a.enumerable });
return e;
}, us = (e, r, s) => (s = e != null ? Lh(jh(e)) : {}, Vo(r || !e || !e.__esModule ? Hs(s, "default", { value: e, enumerable: !0 }) : s, e)), Rh = (e) => Vo(Hs({}, "__esModule", { value: !0 }), e), Uh = (e, r, s) => {
if (!r.has(e))
throw TypeError("Cannot " + s);
}, Ua = (e, r, s) => {
if (r.has(e))
throw TypeError("Cannot add the same private member more than once");
r instanceof WeakSet ? r.add(e) : r.set(e, s);
}, zr = (e, r, s) => (Uh(e, r, "access private method"), s), qh = Ks((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.default = r;
function r() {
}
r.prototype = { diff: function(u, l) {
var p = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, h = p.callback;
typeof p == "function" && (h = p, p = {}), this.options = p;
var y = this;
function m(k) {
return h ? (setTimeout(function() {
h(void 0, k);
}, 0), !0) : k;
}
u = this.castInput(u), l = this.castInput(l), u = this.removeEmpty(this.tokenize(u)), l = this.removeEmpty(this.tokenize(l));
var x = l.length, g = u.length, D = 1, b = x + g;
p.maxEditLength && (b = Math.min(b, p.maxEditLength));
var F = [{ newPos: -1, components: [] }], v = this.extractCommon(F[0], l, u, 0);
if (F[0].newPos + 1 >= x && v + 1 >= g)
return m([{ value: this.join(l), count: l.length }]);
function S() {
for (var k = -1 * D; k <= D; k += 2) {
var E = void 0, R = F[k - 1], O = F[k + 1], B = (O ? O.newPos : 0) - k;
R && (F[k - 1] = void 0);
var Y = R && R.newPos + 1 < x, Z = O && 0 <= B && B < g;
if (!Y && !Z) {
F[k] = void 0;
continue;
}
if (!Y || Z && R.newPos < O.newPos ? (E = a(O), y.pushComponent(E.components, void 0, !0)) : (E = R, E.newPos++, y.pushComponent(E.components, !0, void 0)), B = y.extractCommon(E, l, u, k), E.newPos + 1 >= x && B + 1 >= g)
return m(s(y, E.components, l, u, y.useLongestToken));
F[k] = E;
}
D++;
}
if (h)
(function k() {
setTimeout(function() {
if (D > b)
return h();
S() || k();
}, 0);
})();
else
for (; D <= b; ) {
var P = S();
if (P)
return P;
}
}, pushComponent: function(u, l, p) {
var h = u[u.length - 1];
h && h.added === l && h.removed === p ? u[u.length - 1] = { count: h.count + 1, added: l, removed: p } : u.push({ count: 1, added: l, removed: p });
}, extractCommon: function(u, l, p, h) {
for (var y = l.length, m = p.length, x = u.newPos, g = x - h, D = 0; x + 1 < y && g + 1 < m && this.equals(l[x + 1], p[g + 1]); )
x++, g++, D++;
return D && u.components.push({ count: D }), u.newPos = x, g;
}, equals: function(u, l) {
return this.options.comparator ? this.options.comparator(u, l) : u === l || this.options.ignoreCase && u.toLowerCase() === l.toLowerCase();
}, removeEmpty: function(u) {
for (var l = [], p = 0; p < u.length; p++)
u[p] && l.push(u[p]);
return l;
}, castInput: function(u) {
return u;
}, tokenize: function(u) {
return u.split("");
}, join: function(u) {
return u.join("");
} };
function s(u, l, p, h, y) {
for (var m = 0, x = l.length, g = 0, D = 0; m < x; m++) {
var b = l[m];
if (b.removed) {
if (b.value = u.join(h.slice(D, D + b.count)), D += b.count, m && l[m - 1].added) {
var F = l[m - 1];
l[m - 1] = l[m], l[m] = F;
}
} else {
if (!b.added && y) {
var v = p.slice(g, g + b.count);
v = v.map(function(P, k) {
var E = h[D + k];
return E.length > P.length ? E : P;
}), b.value = u.join(v);
} else
b.value = u.join(p.slice(g, g + b.count));
g += b.count, b.added || (D += b.count);
}
}
var S = l[x - 1];
return x > 1 && typeof S.value == "string" && (S.added || S.removed) && u.equals("", S.value) && (l[x - 2].value += S.value, l.pop()), l;
}
function a(u) {
return { newPos: u.newPos, components: u.components.slice(0) };
}
}), Jh = Ks((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.diffArrays = u, e.arrayDiff = void 0;
var r = s(qh());
function s(l) {
return l && l.__esModule ? l : { default: l };
}
var a = new r.default();
e.arrayDiff = a, a.tokenize = function(l) {
return l.slice();
}, a.join = a.removeEmpty = function(l) {
return l;
};
function u(l, p, h) {
return a.diff(l, p, h);
}
}), Gs = Ks((e, r) => {
var s = new Proxy(String, { get: () => s });
r.exports = s;
}), Wo = {};
Xs(Wo, { default: () => Ho, shouldHighlight: () => zo });
var zo, Ho, Vh = _h(() => {
zo = () => !1, Ho = String;
}), Wh = Ks((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.codeFrameColumns = x, e.default = g;
var r = (Vh(), Rh(Wo)), s = Gs(), a = s, u;
function l(D) {
return D ? (u != null || (u = new a.constructor({ enabled: !0, level: 1 })), u) : a;
}
var p = !1;
function h(D) {
return { gutter: D.grey, marker: D.red.bold, message: D.red.bold };
}
var y = /\r\n|[\n\r\u2028\u2029]/;
function m(D, b, F) {
let v = Object.assign({ column: 0, line: -1 }, D.start), S = Object.assign({}, v, D.end), { linesAbove: P = 2, linesBelow: k = 3 } = F || {}, E = v.line, R = v.column, O = S.line, B = S.column, Y = Math.max(E - (P + 1), 0), Z = Math.min(b.length, O + k);
E === -1 && (Y = 0), O === -1 && (Z = b.length);
let $ = O - E, J = {};
if ($)
for (let I = 0; I <= $; I++) {
let xe = I + E;
if (!R)
J[xe] = !0;
else if (I === 0) {
let Ae = b[xe - 1].length;
J[xe] = [R, Ae - R + 1];
} else if (I === $)
J[xe] = [0, B];
else {
let Ae = b[xe - I].length;
J[xe] = [0, Ae];
}
}
else
R === B ? R ? J[E] = [R, 0] : J[E] = !0 : J[E] = [R, B - R];
return { start: Y, end: Z, markerLines: J };
}
function x(D, b, F = {}) {
let v = (F.highlightCode || F.forceColor) && (0, r.shouldHighlight)(F), S = l(F.forceColor), P = h(S), k = (J, I) => v ? J(I) : I, E = D.split(y), { start: R, end: O, markerLines: B } = m(b, E, F), Y = b.start && typeof b.start.column == "number", Z = String(O).length, $ = (v ? (0, r.default)(D, F) : D).split(y, O).slice(R, O).map((J, I) => {
let xe = R + 1 + I, Ae = ` ${` ${xe}`.slice(-Z)} |`, K = B[xe], ue = !B[xe + 1];
if (K) {
let ce = "";
if (Array.isArray(K)) {
let ot = J.slice(0, Math.max(K[0] - 1, 0)).replace(/[^\t]/g, " "), Q = K[1] || 1;
ce = [`
`, k(P.gutter, Ae.replace(/\d/g, " ")), " ", ot, k(P.marker, "^").repeat(Q)].join(""), ue && F.message && (ce += " " + k(P.message, F.message));
}
return [k(P.marker, ">"), k(P.gutter, Ae), J.length > 0 ? ` ${J}` : "", ce].join("");
} else
return ` ${k(P.gutter, Ae)}${J.length > 0 ? ` ${J}` : ""}`;
}).join(`
`);
return F.message && !Y && ($ = `${" ".repeat(Z + 1)}${F.message}
${$}`), v ? S.reset($) : $;
}
function g(D, b, F, v = {}) {
if (!p) {
p = !0;
let S = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
{
let P = new Error(S);
P.name = "DeprecationWarning", console.warn(new Error(S));
}
}
return F = Math.max(F, 0), x(D, { start: { column: F, line: b } }, v);
}
}), Ko = {};
Xs(Ko, { __debug: () => Lu, check: () => Nu, doc: () => Ln, format: () => si, formatWithCursor: () => Mn, getSupportInfo: () => Iu, util: () => wn, version: () => ku });
var zh = (e, r, s, a) => {
if (!(e && r == null))
return r.replaceAll ? r.replaceAll(s, a) : s.global ? r.replace(s, a) : r.split(s).join(a);
}, Ys = zh, Hh = us(Jh(), 1), ir = "string", Lt = "array", nr = "cursor", ft = "indent", Dt = "align", xt = "trim", Me = "group", qe = "fill", $e = "if-break", gt = "indent-if-break", Et = "line-suffix", At = "line-suffix-boundary", Te = "line", at = "label", Je = "break-parent", Xo = /* @__PURE__ */ new Set([nr, ft, Dt, xt, Me, qe, $e, gt, Et, At, Te, at, Je]);
function Kh(e) {
if (typeof e == "string")
return ir;
if (Array.isArray(e))
return Lt;
if (!e)
return;
let { type: r } = e;
if (Xo.has(r))
return r;
}
var ar = Kh, Xh = (e) => new Intl.ListFormat("en-US", { type: "disjunction" }).format(e);
function Gh(e) {
let r = e === null ? "null" : typeof e;
if (r !== "string" && r !== "object")
return `Unexpected doc '${r}',
Expected it to be 'string' or 'object'.`;
if (ar(e))
throw new Error("doc is valid.");
let s = Object.prototype.toString.call(e);
if (s !== "[object Object]")
return `Unexpected doc '${s}'.`;
let a = Xh([...Xo].map((u) => `'${u}'`));
return `Unexpected doc.type '${e.type}'.
Expected it to be ${a}.`;
}
var Yh = class extends Error {
constructor(s) {
super(Gh(s));
Ht(this, "name", "InvalidDocError");
this.doc = s;
}
}, br = Yh, qa = {};
function Qh(e, r, s, a) {
let u = [e];
for (; u.length > 0; ) {
let l = u.pop();
if (l === qa) {
s(u.pop());
continue;
}
s && u.push(l, qa);
let p = ar(l);
if (!p)
throw new br(l);
if ((r == null ? void 0 : r(l)) !== !1)
switch (p) {
case Lt:
case qe: {
let h = p === Lt ? l : l.parts;
for (let y = h.length, m = y - 1; m >= 0; --m)
u.push(h[m]);
break;
}
case $e:
u.push(l.flatContents, l.breakContents);
break;
case Me:
if (a && l.expandedStates)
for (let h = l.expandedStates.length, y = h - 1; y >= 0; --y)
u.push(l.expandedStates[y]);
else
u.push(l.contents);
break;
case Dt:
case ft:
case gt:
case at:
case Et:
u.push(l.contents);
break;
case ir:
case nr:
case xt:
case At:
case Te:
case Je:
break;
default:
throw new br(l);
}
}
}
var En = Qh, Zh = () => {
}, ed = Zh;
function Rs(e) {
return { type: ft, contents: e };
}
function Sr(e, r) {
return { type: Dt, contents: r, n: e };
}
function Go(e, r = {}) {
return ed(r.expandedStates), { type: Me, id: r.id, contents: e, break: !!r.shouldBreak, expandedStates: r.expandedStates };
}
function td(e) {
return Sr(Number.NEGATIVE_INFINITY, e);
}
function rd(e) {
return Sr({ type: "root" }, e);
}
function sd(e) {
return Sr(-1, e);
}
function id(e, r) {
return Go(e[0], { ...r, expandedStates: e });
}
function Yo(e) {
return { type: qe, parts: e };
}
function nd(e, r = "", s = {}) {
return { type: $e, breakContents: e, flatContents: r, groupId: s.groupId };
}
function ad(e, r) {
return { type: gt, contents: e, groupId: r.groupId, negate: r.negate };
}
function Hi(e) {
return { type: Et, contents: e };
}
var od = { type: At }, Qs = { type: Je }, ud = { type: xt }, An = { type: Te, hard: !0 }, Qo = { type: Te, hard: !0, literal: !0 }, Zo = { type: Te }, ld = { type: Te, soft: !0 }, Yt = [An, Qs], eu = [Qo, Qs], Ki = { type: nr };
function tu(e, r) {
let s = [];
for (let a = 0; a < r.length; a++)
a !== 0 && s.push(e), s.push(r[a]);
return s;
}
function ru(e, r, s) {
let a = e;
if (r > 0) {
for (let u = 0; u < Math.floor(r / s); ++u)
a = Rs(a);
a = Sr(r % s, a), a = Sr(Number.NEGATIVE_INFINITY, a);
}
return a;
}
function pd(e, r) {
return e ? { type: at, label: e, contents: r } : r;
}
var cd = (e, r, s) => {
if (!(e && r == null))
return Array.isArray(r) || typeof r == "string" ? r[s < 0 ? r.length + s : s] : r.at(s);
}, ge = cd;
function hd(e) {
let r = e.indexOf("\r");
return r >= 0 ? e.charAt(r + 1) === `
` ? "crlf" : "cr" : "lf";
}
function Fn(e) {
switch (e) {
case "cr":
return "\r";
case "crlf":
return `\r
`;
default:
return `
`;
}
}
function su(e, r) {
let s;
switch (r) {
case `
`:
s = /\n/g;
break;
case "\r":
s = /\r/g;
break;
case `\r
`:
s = /\r\n/g;
break;
default:
throw new Error(`Unexpected "eol" ${JSON.stringify(r)}.`);
}
let a = e.match(s);
return a ? a.length : 0;
}
function dd(e) {
return Ys(!1, e, /\r\n?/g, `
`);
}
var md = () => /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\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\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g, yd = { eastAsianWidth(e) {
var r = e.charCodeAt(0), s = e.length == 2 ? e.charCodeAt(1) : 0, a = r;
return 55296 <= r && r <= 56319 && 56320 <= s && s <= 57343 && (r &= 1023, s &= 1023, a = r << 10 | s, a += 65536), a == 12288 || 65281 <= a && a <= 65376 || 65504 <= a && a <= 65510 ? "F" : 4352 <= a && a <= 4447 || 4515 <= a && a <= 4519 || 4602 <= a && a <= 4607 || 9001 <= a && a <= 9002 || 11904 <= a && a <= 11929 || 11931 <= a && a <= 12019 || 12032 <= a && a <= 12245 || 12272 <= a && a <= 12283 || 12289 <= a && a <= 12350 || 12353 <= a && a <= 12438 || 12441 <= a && a <= 12543 || 12549 <= a && a <= 12589 || 12593 <= a && a <= 12686 || 12688 <= a && a <= 12730 || 12736 <= a && a <= 12771 || 12784 <= a && a <= 12830 || 12832 <= a && a <= 12871 || 12880 <= a && a <= 13054 || 13056 <= a && a <= 19903 || 19968 <= a && a <= 42124 || 42128 <= a && a <= 42182 || 43360 <= a && a <= 43388 || 44032 <= a && a <= 55203 || 55216 <= a && a <= 55238 || 55243 <= a && a <= 55291 || 63744 <= a && a <= 64255 || 65040 <= a && a <= 65049 || 65072 <= a && a <= 65106 || 65108 <= a && a <= 65126 || 65128 <= a && a <= 65131 || 110592 <= a && a <= 110593 || 127488 <= a && a <= 127490 || 127504 <= a && a <= 127546 || 127552 <= a && a <= 127560 || 127568 <= a && a <= 127569 || 131072 <= a && a <= 194367 || 177984 <= a && a <= 196605 || 196608 <= a && a <= 262141 ? "W" : "N";
} }, fd = /[^\x20-\x7F]/;
function Dd(e) {
if (!e)
return 0;
if (!fd.test(e))
return e.length;
e = e.replace(md(), " ");
let r = 0;
for (let s of e) {
let a = s.codePointAt(0);
if (a <= 31 || a >= 127 && a <= 159 || a >= 768 && a <= 879)
continue;
let u = yd.eastAsianWidth(s);
r += u === "F" || u === "W" ? 2 : 1;
}
return r;
}
var Cn = Dd, xd = (e) => {
if (Array.isArray(e))
return e;
if (e.type !== qe)
throw new Error(`Expect doc to be 'array' or '${qe}'.`);
return e.parts;
};
function Zs(e, r) {
if (typeof e == "string")
return r(e);
let s = /* @__PURE__ */ new Map();
return a(e);
function a(l) {
if (s.has(l))
return s.get(l);
let p = u(l);
return s.set(l, p), p;
}
function u(l) {
switch (ar(l)) {
case Lt:
return r(l.map(a));
case qe:
return r({ ...l, parts: l.parts.map(a) });
case $e:
return r({ ...l, breakContents: a(l.breakContents), flatContents: a(l.flatContents) });
case Me: {
let { expandedStates: p, contents: h } = l;
return p ? (p = p.map(a), h = p[0]) : h = a(h), r({ ...l, contents: h, expandedStates: p });
}
case Dt:
case ft:
case gt:
case at:
case Et:
return r({ ...l, contents: a(l.contents) });
case ir:
case nr:
case xt:
case At:
case Te:
case Je:
return r(l);
default:
throw new br(l);
}
}
}
function Tn(e, r, s) {
let a = s, u = !1;
function l(p) {
if (u)
return !1;
let h = r(p);
h !== void 0 && (u = !0, a = h);
}
return En(e, l), a;
}
function gd(e) {
if (e.type === Me && e.break || e.type === Te && e.hard || e.type === Je)
return !0;
}
function Ed(e) {
return Tn(e, gd, !1);
}
function Ja(e) {
if (e.length > 0) {
let r = ge(!1, e, -1);
!r.expandedStates && !r.break && (r.break = "propagated");
}
return null;
}
function Ad(e) {
let r = /* @__PURE__ */ new Set(), s = [];
function a(l) {
if (l.type === Je && Ja(s), l.type === Me) {
if (s.push(l), r.has(l))
return !1;
r.add(l);
}
}
function u(l) {
l.type === Me && s.pop().break && Ja(s);
}
En(e, a, u, !0);
}
function Fd(e) {
return e.type === Te && !e.hard ? e.soft ? "" : " " : e.type === $e ? e.flatContents : e;
}
function Cd(e) {
return Zs(e, Fd);
}
function Va(e) {
for (e = [...e]; e.length >= 2 && ge(!1, e, -2).type === Te && ge(!1, e, -1).type === Je; )
e.length -= 2;
if (e.length > 0) {
let r = Yr(ge(!1, e, -1));
e[e.length - 1] = r;
}
return e;
}
function Yr(e) {
switch (ar(e)) {
case Dt:
case ft:
case gt:
case Me:
case Et:
case at: {
let r = Yr(e.contents);
return { ...e, contents: r };
}
case $e:
return { ...e, breakContents: Yr(e.breakContents), flatContents: Yr(e.flatContents) };
case qe:
return { ...e, parts: Va(e.parts) };
case Lt:
return Va(e);
case ir:
return e.replace(/[\n\r]*$/, "");
case nr:
case xt:
case At:
case Te:
case Je:
break;
default:
throw new br(e);
}
return e;
}
function iu(e) {
return Yr(bd(e));
}
function Td(e) {
switch (ar(e)) {
case qe:
if (e.parts.every((r) => r === ""))
return "";
break;
case Me:
if (!e.contents && !e.id && !e.break && !e.expandedStates)
return "";
if (e.contents.type === Me && e.contents.id === e.id && e.contents.break === e.break && e.contents.expandedStates === e.expandedStates)
return e.contents;
break;
case Dt:
case ft:
case gt:
case Et:
if (!e.contents)
return "";
break;
case $e:
if (!e.flatContents && !e.breakContents)
return "";
break;
case Lt: {
let r = [];
for (let s of e) {
if (!s)
continue;
let [a, ...u] = Array.isArray(s) ? s : [s];
typeof a == "string" && typeof ge(!1, r, -1) == "string" ? r[r.length - 1] += a : r.push(a), r.push(...u);
}
return r.length === 0 ? "" : r.length === 1 ? r[0] : r;
}
case ir:
case nr:
case xt:
case At:
case Te:
case at:
case Je:
break;
default:
throw new br(e);
}
return e;
}
function bd(e) {
return Zs(e, (r) => Td(r));
}
function Sd(e, r = eu) {
return Zs(e, (s) => typeof s == "string" ? tu(r, s.split(`
`)) : s);
}
function Pd(e) {
if (e.type === Te)
return !0;
}
function vd(e) {
return Tn(e, Pd, !1);
}
function nu(e, r) {
return e.type === at ? { ...e, contents: r(e.contents) } : r(e);
}
var Ie = Symbol("MODE_BREAK"), tt = Symbol("MODE_FLAT"), Qr = Symbol("cursor");
function au() {
return { value: "", length: 0, queue: [] };
}
function wd(e, r) {
return Xi(e, { type: "indent" }, r);
}
function Bd(e, r, s) {
return r === Number.NEGATIVE_INFINITY ? e.root || au() : r < 0 ? Xi(e, { type: "dedent" }, s) : r ? r.type === "root" ? { ...e, root: e } : Xi(e, { type: typeof r == "string" ? "stringAlign" : "numberAlign", n: r }, s) : e;
}
function Xi(e, r, s) {
let a = r.type === "dedent" ? e.queue.slice(0, -1) : [...e.queue, r], u = "", l = 0, p = 0, h = 0;
for (let F of a)
switch (F.type) {
case "indent":
x(), s.useTabs ? y(1) : m(s.tabWidth);
break;
case "stringAlign":
x(), u += F.n, l += F.n.length;
break;
case "numberAlign":
p += 1, h += F.n;
break;
default:
throw new Error(`Unexpected type '${F.type}'`);
}
return D(), { ...e, value: u, length: l, queue: a };
function y(F) {
u += " ".repeat(F), l += s.tabWidth * F;
}
function m(F) {
u += " ".repeat(F), l += F;
}
function x() {
s.useTabs ? g() : D();
}
function g() {
p > 0 && y(p), b();
}
function D() {
h > 0 && m(h), b();
}
function b() {
p = 0, h = 0;
}
}
function Gi(e) {
let r = 0, s = 0, a = e.length;
e:
for (; a--; ) {
let u = e[a];
if (u === Qr) {
s++;
continue;
}
for (let l = u.length - 1; l >= 0; l--) {
let p = u[l];
if (p === " " || p === " ")
r++;
else {
e[a] = u.slice(0, l + 1);
break e;
}
}
}
if (r > 0 || s > 0)
for (e.length = a + 1; s-- > 0; )
e.push(Qr);
return r;
}
function Ps(e, r, s, a, u, l) {
if (s === Number.POSITIVE_INFINITY)
return !0;
let p = r.length, h = [e], y = [];
for (; s >= 0; ) {
if (h.length === 0) {
if (p === 0)
return !0;
h.push(r[--p]);
continue;
}
let { mode: m, doc: x } = h.pop();
switch (ar(x)) {
case ir:
y.push(x), s -= Cn(x);
break;
case Lt:
case qe: {
let g = xd(x);
for (let D = g.length - 1; D >= 0; D--)
h.push({ mode: m, doc: g[D] });
break;
}
case ft:
case Dt:
case gt:
case at:
h.push({ mode: m, doc: x.contents });
break;
case xt:
s += Gi(y);
break;
case Me: {
if (l && x.break)
return !1;
let g = x.break ? Ie : m, D = x.expandedStates && g === Ie ? ge(!1, x.expandedStates, -1) : x.contents;
h.push({ mode: g, doc: D });
break;
}
case $e: {
let g = (x.groupId ? u[x.groupId] || tt : m) === Ie ? x.breakContents : x.flatContents;
g && h.push({ mode: m, doc: g });
break;
}
case Te:
if (m === Ie || x.hard)
return !0;
x.soft || (y.push(" "), s--);
break;
case Et:
a = !0;
break;
case At:
if (a)
return !1;
break;
}
}
return !1;
}
function ei(e, r) {
let s = {}, a = r.printWidth, u = Fn(r.endOfLine), l = 0, p = [{ ind: au(), mode: Ie, doc: e }], h = [], y = !1, m = [], x = 0;
for (Ad(e); p.length > 0; ) {
let { ind: D, mode: b, doc: F } = p.pop();
switch (ar(F)) {
case ir: {
let v = u !== `
` ? Ys(!1, F, `
`, u) : F;
h.push(v), p.length > 0 && (l += Cn(v));
break;
}
case Lt:
for (let v = F.length - 1; v >= 0; v--)
p.push({ ind: D, mode: b, doc: F[v] });
break;
case nr:
if (x >= 2)
throw new Error("There are too many 'cursor' in doc.");
h.push(Qr), x++;
break;
case ft:
p.push({ ind: wd(D, r), mode: b, doc: F.contents });
break;
case Dt:
p.push({ ind: Bd(D, F.n, r), mode: b, doc: F.contents });
break;
case xt:
l -= Gi(h);
break;
case Me:
switch (b) {
case tt:
if (!y) {
p.push({ ind: D, mode: F.break ? Ie : tt, doc: F.contents });
break;
}
case Ie: {
y = !1;
let v = { ind: D, mode: tt, doc: F.contents }, S = a - l, P = m.length > 0;
if (!F.break && Ps(v, p, S, P, s))
p.push(v);
else if (F.expandedStates) {
let k = ge(!1, F.expandedStates, -1);
if (F.break) {
p.push({ ind: D, mode: Ie, doc: k });
break;
} else
for (let E = 1; E < F.expandedStates.length + 1; E++)
if (E >= F.expandedStates.length) {
p.push({ ind: D, mode: Ie, doc: k });
break;
} else {
let R = F.expandedStates[E], O = { ind: D, mode: tt, doc: R };
if (Ps(O, p, S, P, s)) {
p.push(O);
break;
}
}
} else
p.push({ ind: D, mode: Ie, doc: F.contents });
break;
}
}
F.id && (s[F.id] = ge(!1, p, -1).mode);
break;
case qe: {
let v = a - l, { parts: S } = F;
if (S.length === 0)
break;
let [P, k] = S, E = { ind: D, mode: tt, doc: P }, R = { ind: D, mode: Ie, doc: P }, O = Ps(E, [], v, m.length > 0, s, !0);
if (S.length === 1) {
O ? p.push(E) : p.push(R);
break;
}
let B = { ind: D, mode: tt, doc: k }, Y = { ind: D, mode: Ie, doc: k };
if (S.length === 2) {
O ? p.push(B, E) : p.push(Y, R);
break;
}
S.splice(0, 2);
let Z = { ind: D, mode: b, doc: Yo(S) }, $ = S[0];
Ps({ ind: D, mode: tt, doc: [P, k, $] }, [], v, m.length > 0, s, !0) ? p.push(Z, B, E) : O ? p.push(Z, Y, E) : p.push(Z, Y, R);
break;
}
case $e:
case gt: {
let v = F.groupId ? s[F.groupId] : b;
if (v === Ie) {
let S = F.type === $e ? F.breakContents : F.negate ? F.contents : Rs(F.contents);
S && p.push({ ind: D, mode: b, doc: S });
}
if (v === tt) {
let S = F.type === $e ? F.flatContents : F.negate ? Rs(F.contents) : F.contents;
S && p.push({ ind: D, mode: b, doc: S });
}
break;
}
case Et:
m.push({ ind: D, mode: b, doc: F.contents });
break;
case At:
m.length > 0 && p.push({ ind: D, mode: b, doc: An });
break;
case Te:
switch (b) {
case tt:
if (F.hard)
y = !0;
else {
F.soft || (h.push(" "), l += 1);
break;
}
case Ie:
if (m.length > 0) {
p.push({ ind: D, mode: b, doc: F }, ...m.reverse()), m.length = 0;
break;
}
F.literal ? D.root ? (h.push(u, D.root.value), l = D.root.length) : (h.push(u), l = 0) : (l -= Gi(h), h.push(u + D.value), l = D.length);
break;
}
break;
case at:
p.push({ ind: D, mode: b, doc: F.contents });
break;
case Je:
break;
default:
throw new br(F);
}
p.length === 0 && m.length > 0 && (p.push(...m.reverse()), m.length = 0);
}
let g = h.indexOf(Qr);
if (g !== -1) {
let D = h.indexOf(Qr, g + 1), b = h.slice(0, g).join(""), F = h.slice(g + 1, D).join(""), v = h.slice(D + 1).join("");
return { formatted: b + F + v, cursorNodeStart: b.length, cursorNodeText: F };
}
return { formatted: h.join("") };
}
function ht(e) {
var r;
if (!e)
return "";
if (Array.isArray(e)) {
let s = [];
for (let a of e)
if (Array.isArray(a))
s.push(...ht(a));
else {
let u = ht(a);
u !== "" && s.push(u);
}
return s;
}
return e.type === $e ? { ...e, breakContents: ht(e.breakContents), flatContents: ht(e.flatContents) } : e.type === Me ? { ...e, contents: ht(e.contents), expandedStates: (r = e.expandedStates) == null ? void 0 : r.map(ht) } : e.type === qe ? { type: "fill", parts: e.parts.map(ht) } : e.contents ? { ...e, contents: ht(e.contents) } : e;
}
function kd(e) {
let r = /* @__PURE__ */ Object.create(null), s = /* @__PURE__ */ new Set();
return a(ht(e));
function a(l, p, h) {
var y, m;
if (typeof l == "string")
return JSON.stringify(l);
if (Array.isArray(l)) {
let x = l.map(a).filter(Boolean);
return x.length === 1 ? x[0] : `[${x.join(", ")}]`;
}
if (l.type === Te) {
let x = ((y = h == null ? void 0 : h[p + 1]) == null ? void 0 : y.type) === Je;
return l.literal ? x ? "literalline" : "literallineWithoutBreakParent" : l.hard ? x ? "hardline" : "hardlineWithoutBreakParent" : l.soft ? "softline" : "line";
}
if (l.type === Je)
return ((m = h == null ? void 0 : h[p - 1]) == null ? void 0 : m.type) === Te && h[p - 1].hard ? void 0 : "breakParent";
if (l.type === xt)
return "trim";
if (l.type === ft)
return "indent(" + a(l.contents) + ")";
if (l.type === Dt)
return l.n === Number.NEGATIVE_INFINITY ? "dedentToRoot(" + a(l.contents) + ")" : l.n < 0 ? "dedent(" + a(l.contents) + ")" : l.n.type === "root" ? "markAsRoot(" + a(l.contents) + ")" : "align(" + JSON.stringify(l.n) + ", " + a(l.contents) + ")";
if (l.type === $e)
return "ifBreak(" + a(l.breakContents) + (l.flatContents ? ", " + a(l.flatContents) : "") + (l.groupId ? (l.flatContents ? "" : ', ""') + `, { groupId: ${u(l.groupId)} }` : "") + ")";
if (l.type === gt) {
let x = [];
l.negate && x.push("negate: true"), l.groupId && x.push(`groupId: ${u(l.groupId)}`);
let g = x.length > 0 ? `, { ${x.join(", ")} }` : "";
return `indentIfBreak(${a(l.contents)}${g})`;
}
if (l.type === Me) {
let x = [];
l.break && l.break !== "propagated" && x.push("shouldBreak: true"), l.id && x.push(`id: ${u(l.id)}`);
let g = x.length > 0 ? `, { ${x.join(", ")} }` : "";
return l.expandedStates ? `conditionalGroup([${l.expandedStates.map((D) => a(D)).join(",")}]${g})` : `group(${a(l.contents)}${g})`;
}
if (l.type === qe)
return `fill([${l.parts.map((x) => a(x)).join(", ")}])`;
if (l.type === Et)
return "lineSuffix(" + a(l.contents) + ")";
if (l.type === At)
return "lineSuffixBoundary";
if (l.type === at)
return `label(${JSON.stringify(l.label)}, ${a(l.contents)})`;
throw new Error("Unknown doc type " + l.type);
}
function u(l) {
if (typeof l != "symbol")
return JSON.stringify(String(l));
if (l in r)
return r[l];
let p = l.description || "symbol";
for (let h = 0; ; h++) {
let y = p + (h > 0 ? ` #${h}` : "");
if (!s.has(y))
return s.add(y), r[l] = `Symbol.for(${JSON.stringify(y)})`;
}
}
}
function Nd(e, r, s = 0) {
let a = 0;
for (let u = s; u < e.length; ++u)
e[u] === " " ? a = a + r - a % r : a++;
return a;
}
var bn = Nd, ou = class extends Error {
constructor() {
super(...arguments);
Ht(this, "name", "ConfigError");
}
}, Wa = class extends Error {
constructor() {
super(...arguments);
Ht(this, "name", "UndefinedParserError");
}
}, Id = { cursorOffset: { category: "Special", type: "int", default: -1, range: { start: -1, end: 1 / 0, step: 1 }, description: `Print (to stderr) where a cursor at the given position would move to after formatting.
This option cannot be used with --range-start and --range-end.`, cliCategory: "Editor" }, endOfLine: { category: "Global", type: "choice", default: "lf", description: "Which end of line characters to apply.", choices: [{ value: "lf", description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos" }, { value: "crlf", description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows" }, { value: "cr", description: "Carriage Return character only (\\r), used very rarely" }, { value: "auto", description: `Maintain existing
(mixed values within one file are normalised by looking at what's used after the first line)` }] }, filepath: { category: "Special", type: "path", description: "Specify the input filepath. This will be used to do parser inference.", cliName: "stdin-filepath", cliCategory: "Other", cliDescription: "Path to the file to pretend that stdin comes from." }, insertPragma: { category: "Special", type: "boolean", default: !1, description: "Insert @format pragma into file's first docblock comment.", cliCategory: "Other" }, parser: { category: "Global", type: "choice", default: void 0, description: "Which parser to use.", exception: (e) => typeof e == "string" || typeof e == "function", choices: [{ value: "flow", description: "Flow" }, { value: "babel", description: "JavaScript" }, { value: "babel-flow", description: "Flow" }, { value: "babel-ts", description: "TypeScript" }, { value: "typescript", description: "TypeScript" }, { value: "acorn", description: "JavaScript" }, { value: "espree", description: "JavaScript" }, { value: "meriyah", description: "JavaScript" }, { value: "css", description: "CSS" }, { value: "less", description: "Less" }, { value: "scss", description: "SCSS" }, { value: "json", description: "JSON" }, { value: "json5", description: "JSON5" }, { value: "json-stringify", description: "JSON.stringify" }, { value: "graphql", description: "GraphQL" }, { value: "markdown", description: "Markdown" }, { value: "mdx", description: "MDX" }, { value: "vue", description: "Vue" }, { value: "yaml", description: "YAML" }, { value: "glimmer", description: "Ember / Handlebars" }, { value: "html", description: "HTML" }, { value: "angular", description: "Angular" }, { value: "lwc", description: "Lightning Web Components" }] }, plugins: { type: "path", array: !0, default: [{ value: [] }], category: "Global", description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.", exception: (e) => typeof e == "string" || typeof e == "object", cliName: "plugin", cliCategory: "Config" }, printWidth: { category: "Global", type: "int", default: 80, description: "The line length where Prettier will try wrap.", range: { start: 0, end: 1 / 0, step: 1 } }, rangeEnd: { category: "Special", type: "int", default: 1 / 0, range: { start: 0, end: 1 / 0, step: 1 }, description: `Format code ending at a given character offset (exclusive).
The range will extend forwards to the end of the selected statement.
This option cannot be used with --cursor-offset.`, cliCategory: "Editor" }, rangeStart: { category: "Special", type: "int", default: 0, range: { start: 0, end: 1 / 0, step: 1 }, description: `Format code starting at a given character offset.
The range will extend backwards to the start of the first line containing the selected statement.
This option cannot be used with --cursor-offset.`, cliCategory: "Editor" }, requirePragma: { category: "Special", type: "boolean", default: !1, description: `Require either '@prettier' or '@format' to be present in the file's first docblock comment
in order for it to be formatted.`, cliCategory: "Other" }, tabWidth: { type: "int", category: "Global", default: 2, description: "Number of spaces per indentation level.", range: { start: 0, end: 1 / 0, step: 1 } }, useTabs: { category: "Global", type: "boolean", default: !1, description: "Indent with tabs instead of spaces." }, embeddedLanguageFormatting: { category: "Global", type: "choice", default: "auto", description: "Control how Prettier formats quoted code embedded in the file.", choices: [{ value: "auto", description: "Format embedded code if Prettier can automatically identify it." }, { value: "off", description: "Never automatically format embedded code." }] } };
function uu({ plugins: e = [], showDeprecated: r = !1 } = {}) {
let s = e.flatMap((u) => u.languages ?? []), a = [];
for (let u of Md(Object.assign({}, ...e.map(({ options: l }) => l), Id)))
!r && u.deprecated || (Array.isArray(u.choices) && (r || (u.choices = u.choices.filter((l) => !l.deprecated)), u.name === "parser" && (u.choices = [...u.choices, ...Ld(u.choices, s, e)])), u.pluginDefaults = Object.fromEntries(e.filter((l) => {
var p;
return ((p = l.defaultOptions) == null ? void 0 : p[u.name]) !== void 0;
}).map((l) => [l.name, l.defaultOptions[u.name]])), a.push(u));
return { languages: s, options: a };
}
function* Ld(e, r, s) {
let a = new Set(e.map((u) => u.value));
for (let u of r)
if (u.parsers) {
for (let l of u.parsers)
if (!a.has(l)) {
a.add(l);
let p = s.find((y) => y.parsers && Object.prototype.hasOwnProperty.call(y.parsers, l)), h = u.name;
p != null && p.name && (h += ` (plugin: ${p.name})`), yield { value: l, description: h };
}
}
}
function Md(e) {
let r = [];
for (let [s, a] of Object.entries(e)) {
let u = { name: s, ...a };
Array.isArray(u.default) && (u.default = ge(!1, u.default, -1).value), r.push(u);
}
return r;
}
var Od = (e) => e.split(/[/\\]/).pop();
function za(e, r) {
if (!r)
return;
let s = Od(r).toLowerCase();
return e.find((a) => {
var u, l;
return ((u = a.extensions) == null ? void 0 : u.some((p) => s.endsWith(p))) || ((l = a.filenames) == null ? void 0 : l.some((p) => p.toLowerCase() === s));
});
}
function jd(e, r) {
if (r)
return e.find(({ name: s }) => s.toLowerCase() === r) ?? e.find(({ aliases: s }) => s == null ? void 0 : s.includes(r)) ?? e.find(({ extensions: s }) => s == null ? void 0 : s.includes(`.${r}`));
}
function $d(e, r) {
let s = e.plugins.flatMap((u) => u.languages ?? []), a = jd(s, r.language) ?? za(s, r.physicalFile) ?? za(s, r.file) ?? (r.physicalFile, void 0);
return a == null ? void 0 : a.parsers[0];
}
var _d = $d, Ar = { key: (e) => /^[$_a-zA-Z][$_a-zA-Z0-9]*$/.test(e) ? e : JSON.stringify(e), value(e) {
if (e === null || typeof e != "object")
return JSON.stringify(e);
if (Array.isArray(e))
return `[${e.map((s) => Ar.value(s)).join(", ")}]`;
let r = Object.keys(e);
return r.length === 0 ? "{}" : `{ ${r.map((s) => `${Ar.key(s)}: ${Ar.value(e[s])}`).join(", ")} }`;
}, pair: ({ key: e, value: r }) => Ar.value({ [e]: r }) }, Ha = us(Gs(), 1), Rd = (e, r, { descriptor: s }) => {
let a = [`${Ha.default.yellow(typeof e == "string" ? s.key(e) : s.pair(e))} is deprecated`];
return r && a.push(`we now treat it as ${Ha.default.blue(typeof r == "string" ? s.key(r) : s.pair(r))}`), a.join("; ") + ".";
}, Fr = us(Gs(), 1), lu = Symbol.for("vnopts.VALUE_NOT_EXIST"), Ls = Symbol.for("vnopts.VALUE_UNCHANGED"), Ka = " ".repeat(2), Ud = (e, r, s) => {
let { text: a, list: u } = s.normalizeExpectedResult(s.schemas[e].expected(s)), l = [];
return a && l.push(Xa(e,