mongodb-chatbot-ui
Version:
UI React components for the MongoDB Assistant
1,292 lines • 540 kB
JavaScript
import { jsxs as To, jsx as zt } from "react/jsx-runtime";
import * as jn from "react";
import M, { createContext as Vi, useContext as Ur, useCallback as un, forwardRef as Ju, useMemo as Tn, useState as pn, useEffect as Rt, useRef as Hr, Children as Io, lazy as ed, Fragment as kg, Suspense as Mo } from "react";
import { e as xg, K as _g, k as Sg, s as wg, I as Ng, R as Dg } from "./index8.js";
import { a5 as nd, a6 as Og, a7 as td, a8 as Cg, a9 as rd, aa as Ag, ab as id, ac as ad, ad as Tg, ae as od, w as K, F as k, O as rr, x as Ig, b as Et, m as R, n as xe, d as Zn, U as $t, af as ld, ag as Mg, ah as Fg, X as Zi, E as Rg, e as Lg, ai as oa, L as Pg, o as mt, aj as $g, ak as Bg, al as Hg, $ as Fo, am as sd, r as Rr, an as zg, ao as Ro, ap as Ug, aq as Kg, C as Gg, a2 as cd, ar as Wg, a0 as qg, as as hi, at as jg } from "./index2.js";
import { A as Vg, p as Zg, Q as ud, X as Qa, b as Yg, Z as Xg, s as Qg, r as ft, v as Jg } from "./index4.js";
import { t as li, a as vt, i as si, e as Vn, r as ci, n as kt } from "./glyphCommon-cTThlth0.js";
import { o as ep, a as np, g as tp } from "./LinkDataProvider.js";
import { K as Lo, Q as rp } from "./index7.js";
import { H as Ii, g as Po } from "./index6.js";
import { f as ip, N as dd, y as $o } from "./index9.js";
import { t as ap, h as wa, W as op, Q as Na } from "./index12.js";
import { c as Lr } from "./polished.esm.js";
import { o as lp, B as sp, j as Bo, T as mi, a as Ut, U as cp, r as up } from "./index13.js";
import { P as be, k as dp, F as fp, V as Mi, b as gp, Z as pp, a as fd } from "./index5.js";
import { R as hp, r as gd, N as mp, G as bp } from "./index11.js";
import { p as yp } from "./Refresh.js";
import { useChatbotContext as Ep } from "./useChatbotContext.js";
import { b as vp } from "./utils.js";
import "./X.js";
import "./CheckmarkWithCircle.js";
import "react-dom";
import "./ChatbotProvider.js";
function kp(e) {
return function(n, t, r) {
for (var i = -1, a = Object(n), o = r(n), l = o.length; l--; ) {
var s = o[e ? l : ++i];
if (t(a[s], s, a) === !1)
break;
}
return n;
};
}
var xp = kp, _p = xp, Sp = _p(), wp = Sp, Np = wp, Dp = nd;
function Op(e, n) {
return e && Np(e, n, Dp);
}
var Cp = Op, Ap = Og, Tp = td, Ip = 1, Mp = 2;
function Fp(e, n, t, r) {
var i = t.length, a = i, o = !r;
if (e == null)
return !a;
for (e = Object(e); i--; ) {
var l = t[i];
if (o && l[2] ? l[1] !== e[l[0]] : !(l[0] in e))
return !1;
}
for (; ++i < a; ) {
l = t[i];
var s = l[0], c = e[s], u = l[1];
if (o && l[2]) {
if (c === void 0 && !(s in e))
return !1;
} else {
var d = new Ap();
if (r)
var y = r(c, u, s, e, n, d);
if (!(y === void 0 ? Tp(u, c, Ip | Mp, r, d) : y))
return !1;
}
}
return !0;
}
var Rp = Fp, Lp = Cg;
function Pp(e) {
return e === e && !Lp(e);
}
var pd = Pp, $p = pd, Bp = nd;
function Hp(e) {
for (var n = Bp(e), t = n.length; t--; ) {
var r = n[t], i = e[r];
n[t] = [r, i, $p(i)];
}
return n;
}
var zp = Hp;
function Up(e, n) {
return function(t) {
return t == null ? !1 : t[e] === n && (n !== void 0 || e in Object(t));
};
}
var hd = Up, Kp = Rp, Gp = zp, Wp = hd;
function qp(e) {
var n = Gp(e);
return n.length == 1 && n[0][2] ? Wp(n[0][0], n[0][1]) : function(t) {
return t === e || Kp(t, e, n);
};
}
var jp = qp, Vp = rd;
function Zp(e, n, t) {
var r = e == null ? void 0 : Vp(e, n);
return r === void 0 ? t : r;
}
var Yp = Zp, Xp = td, Qp = Yp, Jp = Ag, eh = id, nh = pd, th = hd, rh = ad, ih = 1, ah = 2;
function oh(e, n) {
return eh(e) && nh(n) ? th(rh(e), n) : function(t) {
var r = Qp(t, e);
return r === void 0 && r === n ? Jp(t, e) : Xp(n, r, ih | ah);
};
}
var lh = oh;
function sh(e) {
return function(n) {
return n == null ? void 0 : n[e];
};
}
var ch = sh, uh = rd;
function dh(e) {
return function(n) {
return uh(n, e);
};
}
var fh = dh, gh = ch, ph = fh, hh = id, mh = ad;
function bh(e) {
return hh(e) ? gh(mh(e)) : ph(e);
}
var yh = bh, Eh = jp, vh = lh, kh = Tg, xh = od, _h = yh;
function Sh(e) {
return typeof e == "function" ? e : e == null ? kh : typeof e == "object" ? xh(e) ? vh(e[0], e[1]) : Eh(e) : _h(e);
}
var wh = Sh, Ho = { 0: 0, 50: 2, 100: 4, 150: 6, 200: 8, 300: 12, 400: 16, 500: 20, 600: 24 };
function g(e, n, t) {
return (n = function(r) {
var i = function(a, o) {
if (typeof a != "object" || !a)
return a;
var l = a[Symbol.toPrimitive];
if (l !== void 0) {
var s = l.call(a, o);
if (typeof s != "object")
return s;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return String(a);
}(r, "string");
return typeof i == "symbol" ? i : i + "";
}(n)) in e ? Object.defineProperty(e, n, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[n] = t, e;
}
var zo, Uo, X = { Disabled: "disabled", Placeholder: "placeholder", Primary: "primary", Secondary: "secondary", Tertiary: "tertiary", InversePrimary: "inversePrimary", InverseSecondary: "inverseSecondary", Info: "info", Warning: "warning", Error: "error", Success: "success", Link: "link", OnError: "onError", OnSuccess: "onSuccess", OnSuccessLink: "onSuccessLink" }, x = { Default: "default", Hover: "hover", Focus: "focus" }, qr = k.black, je = k.blue, Ne = k.gray, Sn = k.green, Hn = k.red, Nh = k.white, lr = k.yellow, Dh = { background: g(g(g(g(g(g(g(g({}, X.Primary, g(g(g({}, x.Default, qr), x.Hover, Ne.dark2), x.Focus, je.dark3)), X.Secondary, g(g(g({}, x.Default, Ne.dark4), x.Hover, Ne.dark2), x.Focus, je.dark3)), X.InversePrimary, g(g(g({}, x.Default, Ne.light2), x.Hover, Ne.light3), x.Focus, je.light2)), X.Info, g(g(g({}, x.Default, je.dark3), x.Hover, je.dark3), x.Focus, je.dark3)), X.Warning, g(g(g({}, x.Default, lr.dark3), x.Hover, lr.dark3), x.Focus, lr.dark3)), X.Success, g(g(g({}, x.Default, Sn.dark3), x.Hover, Sn.dark3), x.Focus, Sn.dark3)), X.Error, g(g(g({}, x.Default, Hn.dark3), x.Hover, Hn.dark3), x.Focus, Hn.dark3)), X.Disabled, g(g(g({}, x.Default, Ne.dark3), x.Hover, Ne.dark3), x.Focus, Ne.dark3)), border: g(g(g(g(g(g(g(g({}, X.Primary, g(g(g({}, x.Default, Ne.base), x.Hover, Ne.base), x.Focus, je.light1)), X.Secondary, g(g(g({}, x.Default, Ne.dark2), x.Hover, Ne.dark2), x.Focus, je.light1)), X.Tertiary, g(g(g({}, x.Default, Ne.dark1), x.Hover, Ne.dark1), x.Focus, je.light1)), X.Success, g(g(g({}, x.Default, Sn.dark1), x.Hover, Sn.dark1), x.Focus, je.light1)), X.Error, g(g(g({}, x.Default, Hn.light1), x.Hover, Hn.light1), x.Focus, je.light1)), X.OnSuccess, g(g(g({}, x.Default, Sn.dark2), x.Hover, Sn.dark2), x.Focus, je.light1)), X.OnError, g(g(g({}, x.Default, Hn.dark2), x.Hover, Hn.dark2), x.Focus, je.light1)), X.Disabled, g(g(g({}, x.Default, Ne.dark2), x.Hover, Ne.dark2), x.Focus, Ne.dark2)), icon: g(g(g(g(g(g(g(g({}, X.Primary, g(g(g({}, x.Default, Ne.light1), x.Hover, Ne.light3), x.Focus, je.light3)), X.Secondary, g(g(g({}, x.Default, Ne.base), x.Hover, Ne.light3), x.Focus, je.light3)), X.InversePrimary, g(g(g({}, x.Default, Nh), x.Hover, qr), x.Focus, je.dark2)), X.Info, g(g(g({}, x.Default, je.light1), x.Hover, je.light1), x.Focus, je.light1)), X.Warning, g(g(g({}, x.Default, lr.base), x.Hover, lr.base), x.Focus, lr.base)), X.Success, g(g(g({}, x.Default, Sn.base), x.Hover, Sn.base), x.Focus, Sn.base)), X.Error, g(g(g({}, x.Default, Hn.light1), x.Hover, Hn.light1), x.Focus, Hn.light1)), X.Disabled, g(g(g({}, x.Default, Ne.dark1), x.Hover, Ne.dark1), x.Focus, Ne.dark1)), text: (g(g(g(g(g(g(g(g(g(g(zo = {}, X.Primary, g(g(g({}, x.Default, Ne.light2), x.Hover, Ne.light2), x.Focus, je.light3)), X.Placeholder, g(g(g({}, x.Default, Ne.dark1), x.Hover, Ne.dark1), x.Focus, Ne.dark1)), X.Secondary, g(g(g({}, x.Default, Ne.light1), x.Hover, Ne.light2), x.Focus, je.light3)), X.InversePrimary, g(g(g({}, x.Default, qr), x.Hover, qr), x.Focus, je.dark2)), X.InverseSecondary, g(g(g({}, x.Default, Ne.dark2), x.Hover, qr), x.Focus, je.dark2)), X.Disabled, g(g(g({}, x.Default, Ne.dark1), x.Hover, Ne.dark1), x.Focus, Ne.dark1)), X.Success, g(g(g({}, x.Default, Sn.light2), x.Hover, Sn.light2), x.Focus, Sn.light2)), X.Error, g(g(g({}, x.Default, Hn.light1), x.Hover, Hn.light1), x.Focus, Hn.light1)), X.OnSuccess, g(g(g({}, x.Default, Sn.light1), x.Hover, Sn.light1), x.Focus, Sn.light1)), X.OnSuccessLink, g(g(g({}, x.Default, Sn.light3), x.Hover, Sn.light3), x.Focus, Sn.light3)), g(g(zo, X.OnError, g(g(g({}, x.Default, Hn.light2), x.Hover, Hn.light2), x.Focus, Hn.light2)), X.Link, g(g(g({}, x.Default, je.light1), x.Hover, je.light1), x.Focus, je.light1))) }, sr = k.black, rn = k.blue, Be = k.gray, hn = k.green, Rn = k.red, cr = k.white, ur = k.yellow, Oh = { background: g(g(g(g(g(g(g(g({}, X.Primary, g(g(g({}, x.Default, cr), x.Hover, Be.light2), x.Focus, rn.light3)), X.Secondary, g(g(g({}, x.Default, Be.light3), x.Hover, Be.light2), x.Focus, rn.light3)), X.InversePrimary, g(g(g({}, x.Default, sr), x.Hover, Be.dark3), x.Focus, rn.dark2)), X.Info, g(g(g({}, x.Default, rn.light3), x.Hover, rn.light3), x.Focus, rn.light3)), X.Warning, g(g(g({}, x.Default, ur.light3), x.Hover, ur.light3), x.Focus, ur.light3)), X.Success, g(g(g({}, x.Default, hn.light3), x.Hover, hn.light3), x.Focus, hn.light3)), X.Error, g(g(g({}, x.Default, Rn.light3), x.Hover, Rn.light3), x.Focus, Rn.light3)), X.Disabled, g(g(g({}, x.Default, Be.light2), x.Hover, Be.light2), x.Focus, Be.light2)), border: g(g(g(g(g(g(g(g({}, X.Primary, g(g(g({}, x.Default, Be.base), x.Hover, Be.base), x.Focus, rn.light1)), X.Secondary, g(g(g({}, x.Default, Be.light2), x.Hover, Be.light2), x.Focus, rn.light1)), X.Tertiary, g(g(g({}, x.Default, Be.light1), x.Hover, Be.light1), x.Focus, rn.light1)), X.Success, g(g(g({}, x.Default, hn.dark1), x.Hover, hn.dark1), x.Focus, rn.light1)), X.Error, g(g(g({}, x.Default, Rn.base), x.Hover, Rn.base), x.Focus, rn.light1)), X.Disabled, g(g(g({}, x.Default, Be.light1), x.Hover, Be.light1), x.Focus, Be.light1)), X.OnSuccess, g(g(g({}, x.Default, hn.light2), x.Hover, hn.light2), x.Focus, hn.light2)), X.OnError, g(g(g({}, x.Default, Rn.light2), x.Hover, Rn.light2), x.Focus, Rn.light2)), icon: g(g(g(g(g(g(g(g({}, X.Primary, g(g(g({}, x.Default, Be.dark1), x.Hover, sr), x.Focus, rn.dark1)), X.Secondary, g(g(g({}, x.Default, Be.base), x.Hover, sr), x.Focus, rn.dark1)), X.InversePrimary, g(g(g({}, x.Default, cr), x.Hover, cr), x.Focus, rn.light2)), X.Info, g(g(g({}, x.Default, rn.base), x.Hover, rn.base), x.Focus, rn.base)), X.Warning, g(g(g({}, x.Default, ur.dark2), x.Hover, ur.dark2), x.Focus, ur.dark2)), X.Success, g(g(g({}, x.Default, hn.dark1), x.Hover, hn.dark1), x.Focus, hn.dark1)), X.Error, g(g(g({}, x.Default, Rn.base), x.Hover, Rn.base), x.Focus, Rn.base)), X.Disabled, g(g(g({}, x.Default, Be.base), x.Hover, Be.base), x.Focus, Be.base)), text: (g(g(g(g(g(g(g(g(g(g(Uo = {}, X.Primary, g(g(g({}, x.Default, sr), x.Hover, sr), x.Focus, rn.dark1)), X.Secondary, g(g(g({}, x.Default, Be.dark1), x.Hover, sr), x.Focus, rn.dark1)), X.InversePrimary, g(g(g({}, x.Default, cr), x.Hover, cr), x.Focus, rn.light2)), X.InverseSecondary, g(g(g({}, x.Default, Be.light1), x.Hover, cr), x.Focus, rn.light2)), X.Disabled, g(g(g({}, x.Default, Be.base), x.Hover, Be.base), x.Focus, Be.base)), X.Success, g(g(g({}, x.Default, hn.dark2), x.Hover, hn.dark2), x.Focus, hn.dark2)), X.Error, g(g(g({}, x.Default, Rn.base), x.Hover, Rn.base), x.Focus, Rn.base)), X.Placeholder, g(g(g({}, x.Default, Be.base), x.Hover, Be.base), x.Focus, Be.base)), X.OnSuccess, g(g(g({}, x.Default, hn.dark2), x.Hover, hn.dark2), x.Focus, hn.dark2)), X.OnSuccessLink, g(g(g({}, x.Default, hn.dark3), x.Hover, hn.dark3), x.Focus, hn.dark3)), g(g(Uo, X.OnError, g(g(g({}, x.Default, Rn.dark2), x.Hover, Rn.dark2), x.Focus, Rn.dark2)), X.Link, g(g(g({}, x.Default, rn.base), x.Hover, rn.base), x.Focus, rn.base))) }, md = g(g({}, K.Dark, Dh), K.Light, Oh), Fi = { Dark: "dark", Light: "light" };
g(g({}, Fi.Light, { default: "0 0 0 2px ".concat(k.white, ", 0 0 0 4px ").concat(k.blue.light1), input: "0 0 0 3px ".concat(k.blue.light1) }), Fi.Dark, { default: "0 0 0 2px ".concat(k.black, ", 0 0 0 4px ").concat(k.blue.light1), input: "0 0 0 3px ".concat(k.blue.light1) });
g(g({}, Fi.Light, { gray: "0 0 0 3px ".concat(k.gray.light2), green: "0 0 0 3px ".concat(k.green.light2), red: "0 0 0 3px ".concat(k.red.light2) }), Fi.Dark, { gray: "0 0 0 3px ".concat(k.gray.dark2), green: "0 0 0 3px ".concat(k.green.dark3), red: "0 0 0 3px ".concat(k.yellow.dark3) });
var Ch = k.black, dr = k.gray, Ah = k.white;
g(g({}, X.Primary, g({}, x.Default, dr.base)), X.Secondary, g({}, x.Default, dr.dark1)), g(g({}, X.Primary, g({}, x.Default, Ch)), X.Secondary, g({}, x.Default, dr.dark4)), g(g({}, X.Primary, g({}, x.Default, dr.base)), X.Secondary, g({}, x.Default, dr.light1)), g(g({}, X.Primary, g({}, x.Default, Ah)), X.Secondary, g({}, x.Default, dr.light3));
var Kt = g(g({}, K.Light, { 1: "color-mix(in srgb, ".concat(k.black, " 15%, transparent)"), 2: "color-mix(in srgb, ".concat(k.black, " 20%, transparent)"), 3: "color-mix(in srgb, ".concat(k.black, " 60%, transparent)"), overflow: "color-mix(in srgb, ".concat(k.gray.dark1, " 30%, transparent)") }), K.Dark, { 1: "transparent", 2: "color-mix(in srgb, #000000 45%, transparent)", 3: "color-mix(in srgb, #000000 60%, transparent)", overflow: "color-mix(in srgb, #000000 30%, transparent)" });
g(g({}, K.Light, { 1: "0px 2px 4px 1px ".concat(Kt[K.Light][1]), 2: "0px 18px 18px -15px ".concat(Kt[K.Light][2]), 3: "0px 8px 20px -8px ".concat(Kt[K.Light][3]), overflow: "0px 2px 4px 1px ".concat(Kt[K.Light].overflow) }), K.Dark, { 1: "unset", 2: "0 18px 18px -15px ".concat(Kt[K.Dark][2]), 3: "0 8px 20px -8px ".concat(Kt[K.Dark][3]), overflow: "0px 2px 4px 1px ".concat(Kt[K.Dark].overflow) });
g(g({}, K.Light, 2), K.Dark, 16);
var kn = { 0: 0, 25: 1, 50: 2, 100: 4, 150: 6, 200: 8, 300: 12, 400: 16, 500: 20, 600: 24, 800: 32, 900: 36, 1e3: 40, 1200: 48, 1400: 56, 1600: 64, 1800: 72, 1: 4, 2: 8, 3: 16, 4: 24, 5: 32, 6: 64, 7: 88 }, Th = { faster: 100, default: 150, slower: 300, slowest: 500 }, Ih = { Body1: 13, Body2: 16 };
const Ko = ["http", "https", "mailto", "tel"];
function Mh(e) {
const n = (e || "").trim(), t = n.charAt(0);
if (t === "#" || t === "/")
return n;
const r = n.indexOf(":");
if (r === -1)
return n;
let i = -1;
for (; ++i < Ko.length; ) {
const a = Ko[i];
if (r === a.length && n.slice(0, a.length).toLowerCase() === a)
return n;
}
return i = n.indexOf("?"), i !== -1 && r > i || (i = n.indexOf("#"), i !== -1 && r > i) ? n : "javascript:void(0)";
}
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
var Fh = function(n) {
return n != null && n.constructor != null && typeof n.constructor.isBuffer == "function" && n.constructor.isBuffer(n);
};
const bd = /* @__PURE__ */ rr(Fh);
function Rh(e) {
return !e || typeof e != "object" ? "" : "position" in e || "type" in e ? Go(e.position) : "start" in e || "end" in e ? Go(e) : "line" in e || "column" in e ? Da(e) : "";
}
function Da(e) {
return Wo(e && e.line) + ":" + Wo(e && e.column);
}
function Go(e) {
return Da(e && e.start) + "-" + Da(e && e.end);
}
function Wo(e) {
return e && typeof e == "number" ? e : 1;
}
class ct extends Error {
/**
* Create a message for `reason` at `place` from `origin`.
*
* When an error is passed in as `reason`, the `stack` is copied.
*
* @param {string | Error | VFileMessage} reason
* Reason for message, uses the stack and message of the error if given.
*
* > 👉 **Note**: you should use markdown.
* @param {Node | NodeLike | Position | Point | null | undefined} [place]
* Place in file where the message occurred.
* @param {string | null | undefined} [origin]
* Place in code where the message originates (example:
* `'my-package:my-rule'` or `'my-rule'`).
* @returns
* Instance of `VFileMessage`.
*/
// To do: next major: expose `undefined` everywhere instead of `null`.
constructor(n, t, r) {
const i = [null, null];
let a = {
// @ts-expect-error: we always follows the structure of `position`.
start: { line: null, column: null },
// @ts-expect-error: "
end: { line: null, column: null }
};
if (super(), typeof t == "string" && (r = t, t = void 0), typeof r == "string") {
const o = r.indexOf(":");
o === -1 ? i[1] = r : (i[0] = r.slice(0, o), i[1] = r.slice(o + 1));
}
t && ("type" in t || "position" in t ? t.position && (a = t.position) : "start" in t || "end" in t ? a = t : ("line" in t || "column" in t) && (a.start = t)), this.name = Rh(t) || "1:1", this.message = typeof n == "object" ? n.message : n, this.stack = "", typeof n == "object" && n.stack && (this.stack = n.stack), this.reason = this.message, this.fatal, this.line = a.start.line, this.column = a.start.column, this.position = a, this.source = i[0], this.ruleId = i[1], this.file, this.actual, this.expected, this.url, this.note;
}
}
ct.prototype.file = "";
ct.prototype.name = "";
ct.prototype.reason = "";
ct.prototype.message = "";
ct.prototype.stack = "";
ct.prototype.fatal = null;
ct.prototype.column = null;
ct.prototype.line = null;
ct.prototype.source = null;
ct.prototype.ruleId = null;
ct.prototype.position = null;
const ht = { basename: Lh, dirname: Ph, extname: $h, join: Bh, sep: "/" };
function Lh(e, n) {
if (n !== void 0 && typeof n != "string")
throw new TypeError('"ext" argument must be a string');
ui(e);
let t = 0, r = -1, i = e.length, a;
if (n === void 0 || n.length === 0 || n.length > e.length) {
for (; i--; )
if (e.charCodeAt(i) === 47) {
if (a) {
t = i + 1;
break;
}
} else
r < 0 && (a = !0, r = i + 1);
return r < 0 ? "" : e.slice(t, r);
}
if (n === e)
return "";
let o = -1, l = n.length - 1;
for (; i--; )
if (e.charCodeAt(i) === 47) {
if (a) {
t = i + 1;
break;
}
} else
o < 0 && (a = !0, o = i + 1), l > -1 && (e.charCodeAt(i) === n.charCodeAt(l--) ? l < 0 && (r = i) : (l = -1, r = o));
return t === r ? r = o : r < 0 && (r = e.length), e.slice(t, r);
}
function Ph(e) {
if (ui(e), e.length === 0)
return ".";
let n = -1, t = e.length, r;
for (; --t; )
if (e.charCodeAt(t) === 47) {
if (r) {
n = t;
break;
}
} else
r || (r = !0);
return n < 0 ? e.charCodeAt(0) === 47 ? "/" : "." : n === 1 && e.charCodeAt(0) === 47 ? "//" : e.slice(0, n);
}
function $h(e) {
ui(e);
let n = e.length, t = -1, r = 0, i = -1, a = 0, o;
for (; n--; ) {
const l = e.charCodeAt(n);
if (l === 47) {
if (o) {
r = n + 1;
break;
}
continue;
}
t < 0 && (o = !0, t = n + 1), l === 46 ? i < 0 ? i = n : a !== 1 && (a = 1) : i > -1 && (a = -1);
}
return i < 0 || t < 0 || // We saw a non-dot character immediately before the dot.
a === 0 || // The (right-most) trimmed path component is exactly `..`.
a === 1 && i === t - 1 && i === r + 1 ? "" : e.slice(i, t);
}
function Bh(...e) {
let n = -1, t;
for (; ++n < e.length; )
ui(e[n]), e[n] && (t = t === void 0 ? e[n] : t + "/" + e[n]);
return t === void 0 ? "." : Hh(t);
}
function Hh(e) {
ui(e);
const n = e.charCodeAt(0) === 47;
let t = zh(e, !n);
return t.length === 0 && !n && (t = "."), t.length > 0 && e.charCodeAt(e.length - 1) === 47 && (t += "/"), n ? "/" + t : t;
}
function zh(e, n) {
let t = "", r = 0, i = -1, a = 0, o = -1, l, s;
for (; ++o <= e.length; ) {
if (o < e.length)
l = e.charCodeAt(o);
else {
if (l === 47)
break;
l = 47;
}
if (l === 47) {
if (!(i === o - 1 || a === 1))
if (i !== o - 1 && a === 2) {
if (t.length < 2 || r !== 2 || t.charCodeAt(t.length - 1) !== 46 || t.charCodeAt(t.length - 2) !== 46) {
if (t.length > 2) {
if (s = t.lastIndexOf("/"), s !== t.length - 1) {
s < 0 ? (t = "", r = 0) : (t = t.slice(0, s), r = t.length - 1 - t.lastIndexOf("/")), i = o, a = 0;
continue;
}
} else if (t.length > 0) {
t = "", r = 0, i = o, a = 0;
continue;
}
}
n && (t = t.length > 0 ? t + "/.." : "..", r = 2);
} else
t.length > 0 ? t += "/" + e.slice(i + 1, o) : t = e.slice(i + 1, o), r = o - i - 1;
i = o, a = 0;
} else
l === 46 && a > -1 ? a++ : a = -1;
}
return t;
}
function ui(e) {
if (typeof e != "string")
throw new TypeError(
"Path must be a string. Received " + JSON.stringify(e)
);
}
const Uh = { cwd: Kh };
function Kh() {
return "/";
}
function Oa(e) {
return e !== null && typeof e == "object" && // @ts-expect-error: indexable.
e.href && // @ts-expect-error: indexable.
e.origin;
}
function Gh(e) {
if (typeof e == "string")
e = new URL(e);
else if (!Oa(e)) {
const n = new TypeError(
'The "path" argument must be of type string or an instance of URL. Received `' + e + "`"
);
throw n.code = "ERR_INVALID_ARG_TYPE", n;
}
if (e.protocol !== "file:") {
const n = new TypeError("The URL must be of scheme file");
throw n.code = "ERR_INVALID_URL_SCHEME", n;
}
return Wh(e);
}
function Wh(e) {
if (e.hostname !== "") {
const r = new TypeError(
'File URL host must be "localhost" or empty on darwin'
);
throw r.code = "ERR_INVALID_FILE_URL_HOST", r;
}
const n = e.pathname;
let t = -1;
for (; ++t < n.length; )
if (n.charCodeAt(t) === 37 && n.charCodeAt(t + 1) === 50) {
const r = n.charCodeAt(t + 2);
if (r === 70 || r === 102) {
const i = new TypeError(
"File URL path must not include encoded / characters"
);
throw i.code = "ERR_INVALID_FILE_URL_PATH", i;
}
}
return decodeURIComponent(n);
}
const la = ["history", "path", "basename", "stem", "extname", "dirname"];
class yd {
/**
* Create a new virtual file.
*
* `options` is treated as:
*
* * `string` or `Buffer` — `{value: options}`
* * `URL` — `{path: options}`
* * `VFile` — shallow copies its data over to the new file
* * `object` — all fields are shallow copied over to the new file
*
* Path related fields are set in the following order (least specific to
* most specific): `history`, `path`, `basename`, `stem`, `extname`,
* `dirname`.
*
* You cannot set `dirname` or `extname` without setting either `history`,
* `path`, `basename`, or `stem` too.
*
* @param {Compatible | null | undefined} [value]
* File value.
* @returns
* New instance.
*/
constructor(n) {
let t;
n ? typeof n == "string" || qh(n) ? t = { value: n } : Oa(n) ? t = { path: n } : t = n : t = {}, this.data = {}, this.messages = [], this.history = [], this.cwd = Uh.cwd(), this.value, this.stored, this.result, this.map;
let r = -1;
for (; ++r < la.length; ) {
const a = la[r];
a in t && t[a] !== void 0 && t[a] !== null && (this[a] = a === "history" ? [...t[a]] : t[a]);
}
let i;
for (i in t)
la.includes(i) || (this[i] = t[i]);
}
/**
* Get the full path (example: `'~/index.min.js'`).
*
* @returns {string}
*/
get path() {
return this.history[this.history.length - 1];
}
/**
* Set the full path (example: `'~/index.min.js'`).
*
* Cannot be nullified.
* You can set a file URL (a `URL` object with a `file:` protocol) which will
* be turned into a path with `url.fileURLToPath`.
*
* @param {string | URL} path
*/
set path(n) {
Oa(n) && (n = Gh(n)), ca(n, "path"), this.path !== n && this.history.push(n);
}
/**
* Get the parent path (example: `'~'`).
*/
get dirname() {
return typeof this.path == "string" ? ht.dirname(this.path) : void 0;
}
/**
* Set the parent path (example: `'~'`).
*
* Cannot be set if there’s no `path` yet.
*/
set dirname(n) {
qo(this.basename, "dirname"), this.path = ht.join(n || "", this.basename);
}
/**
* Get the basename (including extname) (example: `'index.min.js'`).
*/
get basename() {
return typeof this.path == "string" ? ht.basename(this.path) : void 0;
}
/**
* Set basename (including extname) (`'index.min.js'`).
*
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
* on windows).
* Cannot be nullified (use `file.path = file.dirname` instead).
*/
set basename(n) {
ca(n, "basename"), sa(n, "basename"), this.path = ht.join(this.dirname || "", n);
}
/**
* Get the extname (including dot) (example: `'.js'`).
*/
get extname() {
return typeof this.path == "string" ? ht.extname(this.path) : void 0;
}
/**
* Set the extname (including dot) (example: `'.js'`).
*
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
* on windows).
* Cannot be set if there’s no `path` yet.
*/
set extname(n) {
if (sa(n, "extname"), qo(this.dirname, "extname"), n) {
if (n.charCodeAt(0) !== 46)
throw new Error("`extname` must start with `.`");
if (n.includes(".", 1))
throw new Error("`extname` cannot contain multiple dots");
}
this.path = ht.join(this.dirname, this.stem + (n || ""));
}
/**
* Get the stem (basename w/o extname) (example: `'index.min'`).
*/
get stem() {
return typeof this.path == "string" ? ht.basename(this.path, this.extname) : void 0;
}
/**
* Set the stem (basename w/o extname) (example: `'index.min'`).
*
* Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
* on windows).
* Cannot be nullified (use `file.path = file.dirname` instead).
*/
set stem(n) {
ca(n, "stem"), sa(n, "stem"), this.path = ht.join(this.dirname || "", n + (this.extname || ""));
}
/**
* Serialize the file.
*
* @param {BufferEncoding | null | undefined} [encoding='utf8']
* Character encoding to understand `value` as when it’s a `Buffer`
* (default: `'utf8'`).
* @returns {string}
* Serialized file.
*/
toString(n) {
return (this.value || "").toString(n || void 0);
}
/**
* Create a warning message associated with the file.
*
* Its `fatal` is set to `false` and `file` is set to the current file path.
* Its added to `file.messages`.
*
* @param {string | Error | VFileMessage} reason
* Reason for message, uses the stack and message of the error if given.
* @param {Node | NodeLike | Position | Point | null | undefined} [place]
* Place in file where the message occurred.
* @param {string | null | undefined} [origin]
* Place in code where the message originates (example:
* `'my-package:my-rule'` or `'my-rule'`).
* @returns {VFileMessage}
* Message.
*/
message(n, t, r) {
const i = new ct(n, t, r);
return this.path && (i.name = this.path + ":" + i.name, i.file = this.path), i.fatal = !1, this.messages.push(i), i;
}
/**
* Create an info message associated with the file.
*
* Its `fatal` is set to `null` and `file` is set to the current file path.
* Its added to `file.messages`.
*
* @param {string | Error | VFileMessage} reason
* Reason for message, uses the stack and message of the error if given.
* @param {Node | NodeLike | Position | Point | null | undefined} [place]
* Place in file where the message occurred.
* @param {string | null | undefined} [origin]
* Place in code where the message originates (example:
* `'my-package:my-rule'` or `'my-rule'`).
* @returns {VFileMessage}
* Message.
*/
info(n, t, r) {
const i = this.message(n, t, r);
return i.fatal = null, i;
}
/**
* Create a fatal error associated with the file.
*
* Its `fatal` is set to `true` and `file` is set to the current file path.
* Its added to `file.messages`.
*
* > 👉 **Note**: a fatal error means that a file is no longer processable.
*
* @param {string | Error | VFileMessage} reason
* Reason for message, uses the stack and message of the error if given.
* @param {Node | NodeLike | Position | Point | null | undefined} [place]
* Place in file where the message occurred.
* @param {string | null | undefined} [origin]
* Place in code where the message originates (example:
* `'my-package:my-rule'` or `'my-rule'`).
* @returns {never}
* Message.
* @throws {VFileMessage}
* Message.
*/
fail(n, t, r) {
const i = this.message(n, t, r);
throw i.fatal = !0, i;
}
}
function sa(e, n) {
if (e && e.includes(ht.sep))
throw new Error(
"`" + n + "` cannot be a path: did not expect `" + ht.sep + "`"
);
}
function ca(e, n) {
if (!e)
throw new Error("`" + n + "` cannot be empty");
}
function qo(e, n) {
if (!e)
throw new Error("Setting `" + n + "` requires `path` to be set too");
}
function qh(e) {
return bd(e);
}
function jo(e) {
if (e)
throw e;
}
var Di = Object.prototype.hasOwnProperty, Ed = Object.prototype.toString, Vo = Object.defineProperty, Zo = Object.getOwnPropertyDescriptor, Yo = function(n) {
return typeof Array.isArray == "function" ? Array.isArray(n) : Ed.call(n) === "[object Array]";
}, Xo = function(n) {
if (!n || Ed.call(n) !== "[object Object]")
return !1;
var t = Di.call(n, "constructor"), r = n.constructor && n.constructor.prototype && Di.call(n.constructor.prototype, "isPrototypeOf");
if (n.constructor && !t && !r)
return !1;
var i;
for (i in n)
;
return typeof i > "u" || Di.call(n, i);
}, Qo = function(n, t) {
Vo && t.name === "__proto__" ? Vo(n, t.name, {
enumerable: !0,
configurable: !0,
value: t.newValue,
writable: !0
}) : n[t.name] = t.newValue;
}, Jo = function(n, t) {
if (t === "__proto__")
if (Di.call(n, t)) {
if (Zo)
return Zo(n, t).value;
} else
return;
return n[t];
}, jh = function e() {
var n, t, r, i, a, o, l = arguments[0], s = 1, c = arguments.length, u = !1;
for (typeof l == "boolean" && (u = l, l = arguments[1] || {}, s = 2), (l == null || typeof l != "object" && typeof l != "function") && (l = {}); s < c; ++s)
if (n = arguments[s], n != null)
for (t in n)
r = Jo(l, t), i = Jo(n, t), l !== i && (u && i && (Xo(i) || (a = Yo(i))) ? (a ? (a = !1, o = r && Yo(r) ? r : []) : o = r && Xo(r) ? r : {}, Qo(l, { name: t, newValue: e(u, o, i) })) : typeof i < "u" && Qo(l, { name: t, newValue: i }));
return l;
};
const el = /* @__PURE__ */ rr(jh);
function Ca(e) {
if (typeof e != "object" || e === null)
return !1;
const n = Object.getPrototypeOf(e);
return (n === null || n === Object.prototype || Object.getPrototypeOf(n) === null) && !(Symbol.toStringTag in e) && !(Symbol.iterator in e);
}
function Vh() {
const e = [], n = { run: t, use: r };
return n;
function t(...i) {
let a = -1;
const o = i.pop();
if (typeof o != "function")
throw new TypeError("Expected function as last argument, not " + o);
l(null, ...i);
function l(s, ...c) {
const u = e[++a];
let d = -1;
if (s) {
o(s);
return;
}
for (; ++d < i.length; )
(c[d] === null || c[d] === void 0) && (c[d] = i[d]);
i = c, u ? Zh(u, l)(...c) : o(null, ...c);
}
}
function r(i) {
if (typeof i != "function")
throw new TypeError(
"Expected `middelware` to be a function, not " + i
);
return e.push(i), n;
}
}
function Zh(e, n) {
let t;
return r;
function r(...o) {
const l = e.length > o.length;
let s;
l && o.push(i);
try {
s = e.apply(this, o);
} catch (c) {
const u = (
/** @type {Error} */
c
);
if (l && t)
throw u;
return i(u);
}
l || (s && s.then && typeof s.then == "function" ? s.then(a, i) : s instanceof Error ? i(s) : a(s));
}
function i(o, ...l) {
t || (t = !0, n(o, ...l));
}
function a(o) {
i(null, o);
}
}
const Yh = kd().freeze(), vd = {}.hasOwnProperty;
function kd() {
const e = Vh(), n = [];
let t = {}, r, i = -1;
return a.data = o, a.Parser = void 0, a.Compiler = void 0, a.freeze = l, a.attachers = n, a.use = s, a.parse = c, a.stringify = u, a.run = d, a.runSync = y, a.process = f, a.processSync = w, a;
function a() {
const _ = kd();
let T = -1;
for (; ++T < n.length; )
_.use(...n[T]);
return _.data(el(!0, {}, t)), _;
}
function o(_, T) {
return typeof _ == "string" ? arguments.length === 2 ? (fa("data", r), t[_] = T, a) : vd.call(t, _) && t[_] || null : _ ? (fa("data", r), t = _, a) : t;
}
function l() {
if (r)
return a;
for (; ++i < n.length; ) {
const [_, ...T] = n[i];
if (T[0] === !1)
continue;
T[0] === !0 && (T[0] = void 0);
const A = _.call(a, ...T);
typeof A == "function" && e.use(A);
}
return r = !0, i = Number.POSITIVE_INFINITY, a;
}
function s(_, ...T) {
let A;
if (fa("use", r), _ != null)
if (typeof _ == "function")
U(_, ...T);
else if (typeof _ == "object")
Array.isArray(_) ? H(_) : F(_);
else
throw new TypeError("Expected usable value, not `" + _ + "`");
return A && (t.settings = Object.assign(t.settings || {}, A)), a;
function z(C) {
if (typeof C == "function")
U(C);
else if (typeof C == "object")
if (Array.isArray(C)) {
const [L, ...G] = C;
U(L, ...G);
} else
F(C);
else
throw new TypeError("Expected usable value, not `" + C + "`");
}
function F(C) {
H(C.plugins), C.settings && (A = Object.assign(A || {}, C.settings));
}
function H(C) {
let L = -1;
if (C != null)
if (Array.isArray(C))
for (; ++L < C.length; ) {
const G = C[L];
z(G);
}
else
throw new TypeError("Expected a list of plugins, not `" + C + "`");
}
function U(C, L) {
let G = -1, Y;
for (; ++G < n.length; )
if (n[G][0] === C) {
Y = n[G];
break;
}
Y ? (Ca(Y[1]) && Ca(L) && (L = el(!0, Y[1], L)), Y[1] = L) : n.push([...arguments]);
}
}
function c(_) {
a.freeze();
const T = jr(_), A = a.Parser;
return ua("parse", A), nl(A, "parse") ? new A(String(T), T).parse() : A(String(T), T);
}
function u(_, T) {
a.freeze();
const A = jr(T), z = a.Compiler;
return da("stringify", z), tl(_), nl(z, "compile") ? new z(_, A).compile() : z(_, A);
}
function d(_, T, A) {
if (tl(_), a.freeze(), !A && typeof T == "function" && (A = T, T = void 0), !A)
return new Promise(z);
z(null, A);
function z(F, H) {
e.run(_, jr(T), U);
function U(C, L, G) {
L = L || _, C ? H(C) : F ? F(L) : A(null, L, G);
}
}
}
function y(_, T) {
let A, z;
return a.run(_, T, F), rl("runSync", "run", z), A;
function F(H, U) {
jo(H), A = U, z = !0;
}
}
function f(_, T) {
if (a.freeze(), ua("process", a.Parser), da("process", a.Compiler), !T)
return new Promise(A);
A(null, T);
function A(z, F) {
const H = jr(_);
a.run(a.parse(H), H, (C, L, G) => {
if (C || !L || !G)
U(C);
else {
const Y = a.stringify(L, G);
Y == null || (Jh(Y) ? G.value = Y : G.result = Y), U(C, G);
}
});
function U(C, L) {
C || !L ? F(C) : z ? z(L) : T(null, L);
}
}
}
function w(_) {
let T;
a.freeze(), ua("processSync", a.Parser), da("processSync", a.Compiler);
const A = jr(_);
return a.process(A, z), rl("processSync", "process", T), A;
function z(F) {
T = !0, jo(F);
}
}
}
function nl(e, n) {
return typeof e == "function" && // Prototypes do exist.
// type-coverage:ignore-next-line
e.prototype && // A function with keys in its prototype is probably a constructor.
// Classes’ prototype methods are not enumerable, so we check if some value
// exists in the prototype.
// type-coverage:ignore-next-line
(Xh(e.prototype) || n in e.prototype);
}
function Xh(e) {
let n;
for (n in e)
if (vd.call(e, n))
return !0;
return !1;
}
function ua(e, n) {
if (typeof n != "function")
throw new TypeError("Cannot `" + e + "` without `Parser`");
}
function da(e, n) {
if (typeof n != "function")
throw new TypeError("Cannot `" + e + "` without `Compiler`");
}
function fa(e, n) {
if (n)
throw new Error(
"Cannot call `" + e + "` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`."
);
}
function tl(e) {
if (!Ca(e) || typeof e.type != "string")
throw new TypeError("Expected node, got `" + e + "`");
}
function rl(e, n, t) {
if (!t)
throw new Error(
"`" + e + "` finished async. Use `" + n + "` instead"
);
}
function jr(e) {
return Qh(e) ? e : new yd(e);
}
function Qh(e) {
return !!(e && typeof e == "object" && "message" in e && "messages" in e);
}
function Jh(e) {
return typeof e == "string" || bd(e);
}
const em = {};
function nm(e, n) {
const t = n || em, r = typeof t.includeImageAlt == "boolean" ? t.includeImageAlt : !0, i = typeof t.includeHtml == "boolean" ? t.includeHtml : !0;
return xd(e, r, i);
}
function xd(e, n, t) {
if (tm(e)) {
if ("value" in e)
return e.type === "html" && !t ? "" : e.value;
if (n && "alt" in e && e.alt)
return e.alt;
if ("children" in e)
return il(e.children, n, t);
}
return Array.isArray(e) ? il(e, n, t) : "";
}
function il(e, n, t) {
const r = [];
let i = -1;
for (; ++i < e.length; )
r[i] = xd(e[i], n, t);
return r.join("");
}
function tm(e) {
return !!(e && typeof e == "object");
}
function xt(e, n, t, r) {
const i = e.length;
let a = 0, o;
if (n < 0 ? n = -n > i ? 0 : i + n : n = n > i ? i : n, t = t > 0 ? t : 0, r.length < 1e4)
o = Array.from(r), o.unshift(n, t), e.splice(...o);
else
for (t && e.splice(n, t); a < r.length; )
o = r.slice(a, a + 1e4), o.unshift(n, 0), e.splice(...o), a += 1e4, n += 1e4;
}
function st(e, n) {
return e.length > 0 ? (xt(e, e.length, 0, n), e) : n;
}
const al = {}.hasOwnProperty;
function rm(e) {
const n = {};
let t = -1;
for (; ++t < e.length; )
im(n, e[t]);
return n;
}
function im(e, n) {
let t;
for (t in n) {
const i = (al.call(e, t) ? e[t] : void 0) || (e[t] = {}), a = n[t];
let o;
if (a)
for (o in a) {
al.call(i, o) || (i[o] = []);
const l = a[o];
am(
// @ts-expect-error Looks like a list.
i[o],
Array.isArray(l) ? l : l ? [l] : []
);
}
}
}
function am(e, n) {
let t = -1;
const r = [];
for (; ++t < n.length; )
(n[t].add === "after" ? e : r).push(n[t]);
xt(e, 0, 0, r);
}
const om = /[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/, bt = Bt(/[A-Za-z]/), gt = Bt(/[\dA-Za-z]/), lm = Bt(/[#-'*+\--9=?A-Z^-~]/);
function Aa(e) {
return (
// Special whitespace codes (which have negative values), C0 and Control
// character DEL
e !== null && (e < 32 || e === 127)
);
}
const Ta = Bt(/\d/), sm = Bt(/[\dA-Fa-f]/), cm = Bt(/[!-/:-@[-`{-~]/);
function me(e) {
return e !== null && e < -2;
}
function et(e) {
return e !== null && (e < 0 || e === 32);
}
function Re(e) {
return e === -2 || e === -1 || e === 32;
}
const um = Bt(om), dm = Bt(/\s/);
function Bt(e) {
return n;
function n(t) {
return t !== null && e.test(String.fromCharCode(t));
}
}
function en(e, n, t, r) {
const i = r ? r - 1 : Number.POSITIVE_INFINITY;
let a = 0;
return o;
function o(s) {
return Re(s) ? (e.enter(t), l(s)) : n(s);
}
function l(s) {
return Re(s) && a++ < i ? (e.consume(s), l) : (e.exit(t), n(s));
}
}
const fm = {
tokenize: gm
};
function gm(e) {
const n = e.attempt(
this.parser.constructs.contentInitial,
r,
i
);
let t;
return n;
function r(l) {
if (l === null) {
e.consume(l);
return;
}
return e.enter("lineEnding"), e.consume(l), e.exit("lineEnding"), en(e, n, "linePrefix");
}
function i(l) {
return e.enter("paragraph"), a(l);
}
function a(l) {
const s = e.enter("chunkText", {
contentType: "text",
previous: t
});
return t && (t.next = s), t = s, o(l);
}
function o(l) {
if (l === null) {
e.exit("chunkText"), e.exit("paragraph"), e.consume(l);
return;
}
return me(l) ? (e.consume(l), e.exit("chunkText"), a) : (e.consume(l), o);
}
}
const pm = {
tokenize: hm
}, ol = {
tokenize: mm
};
function hm(e) {
const n = this, t = [];
let r = 0, i, a, o;
return l;
function l(F) {
if (r < t.length) {
const H = t[r];
return n.containerState = H[1], e.attempt(
H[0].continuation,
s,
c
)(F);
}
return c(F);
}
function s(F) {
if (r++, n.containerState._closeFlow) {
n.containerState._closeFlow = void 0, i && z();
const H = n.events.length;
let U = H, C;
for (; U--; )
if (n.events[U][0] === "exit" && n.events[U][1].type === "chunkFlow") {
C = n.events[U][1].end;
break;
}
A(r);
let L = H;
for (; L < n.events.length; )
n.events[L][1].end = Object.assign({}, C), L++;
return xt(
n.events,
U + 1,
0,
n.events.slice(H)
), n.events.length = L, c(F);
}
return l(F);
}
function c(F) {
if (r === t.length) {
if (!i)
return y(F);
if (i.currentConstruct && i.currentConstruct.concrete)
return w(F);
n.interrupt = !!(i.currentConstruct && !i._gfmTableDynamicInterruptHack);
}
return n.containerState = {}, e.check(
ol,
u,
d
)(F);
}
function u(F) {
return i && z(), A(r), y(F);
}
function d(F) {
return n.parser.lazy[n.now().line] = r !== t.length, o = n.now().offset, w(F);
}
function y(F) {
return n.containerState = {}, e.attempt(
ol,
f,
w
)(F);
}
function f(F) {
return r++, t.push([n.currentConstruct, n.containerState]), y(F);
}
function w(F) {
if (F === null) {
i && z(), A(0), e.consume(F);
return;
}
return i = i || n.parser.flow(n.now()), e.enter("chunkFlow", {
contentType: "flow",
previous: a,
_tokenizer: i
}), _(F);
}
function _(F) {
if (F === null) {
T(e.exit("chunkFlow"), !0), A(0), e.consume(F);
return;
}
return me(F) ? (e.consume(F), T(e.exit("chunkFlow")), r = 0, n.interrupt = void 0, l) : (e.consume(F), _);
}
function T(F, H) {
const U = n.sliceStream(F);
if (H && U.push(null), F.previous = a, a && (a.next = F), a = F, i.defineSkip(F.start), i.write(U), n.parser.lazy[F.start.line]) {
let C = i.events.length;
for (; C--; )
if (
// The token starts before the line ending…
i.events[C][1].start.offset < o && // …and either is not ended yet…
(!i.events[C][1].end || // …or ends after it.
i.events[C][1].end.offset > o)
)
return;
const L = n.events.length;
let G = L, Y, ae;
for (; G--; )
if (n.events[G][0] === "exit" && n.events[G][1].type === "chunkFlow") {
if (Y) {
ae = n.events[G][1].end;
break;
}
Y = !0;
}
for (A(r), C = L; C < n.events.length; )
n.events[C][1].end = Object.assign({}, ae), C++;
xt(
n.events,
G + 1,
0,
n.events.slice(L)
), n.events.length = C;
}
}
function A(F) {
let H = t.length;
for (; H-- > F; ) {
const U = t[H];
n.containerState = U[1], U[0].exit.call(n, e);
}
t.length = F;
}
function z() {
i.write([null]), a = void 0, i = void 0, n.containerState._closeFlow = void 0;
}
}
function mm(e, n, t) {
return en(
e,
e.attempt(this.parser.constructs.document, n, t),
"linePrefix",
this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4
);
}
function ll(e) {
if (e === null || et(e) || dm(e))
return 1;
if (um(e))
return 2;
}
function Ja(e, n, t) {
const r = [];
let i = -1;
for (; ++i < e.length; ) {
const a = e[i].resolveAll;
a && !r.includes(a) && (n = a(n, t), r.push(a));
}
return n;
}
const Ia = {
name: "attention",
tokenize: ym,
resolveAll: bm
};
function bm(e, n) {
let t = -1, r, i, a, o, l, s, c, u;
for (; ++t < e.length; )
if (e[t][0] === "enter" && e[t][1].type === "attentionSequence" && e[t][1]._close) {
for (r = t; r--; )
if (e[r][0] === "exit" && e[r][1].type === "attentionSequence" && e[r][1]._open && // If the markers are the same:
n.sliceSerialize(e[r][1]).charCodeAt(0) === n.sliceSerialize(e[t][1]).charCodeAt(0)) {
if ((e[r][1]._close || e[t][1]._open) && (e[t][1].end.offset - e[t][1].start.offset) % 3 && !((e[r][1].end.offset - e[r][1].start.offset + e[t][1].end.offset - e[t][1].start.offset) % 3))
continue;
s = e[r][1].end.offset - e[r][1].start.offset > 1 && e[t][1].end.offset - e[t][1].start.offset > 1 ? 2 : 1;
const d = Object.assign({}, e[r][1].end), y = Object.assign({}, e[t][1].start);
sl(d, -s), sl(y, s), o = {
type: s > 1 ? "strongSequence" : "emphasisSequence",
start: d,
end: Object.assign({}, e[r][1].end)
}, l = {
type: s > 1 ? "strongSequence" : "emphasisSequence",
start: Object.assign({}, e[t][1].start),
end: y
}, a = {
type: s > 1 ? "strongText" : "emphasisText",
start: Object.assign({}, e[r][1].end),
end: Object.assign({}, e[t][1].start)
}, i = {
type: s > 1 ? "strong" : "emphasis",
start: Object.assign({}, o.start),
end: Object.assign({}, l.end)
}, e[r][1].end = Object.assign({}, o.start), e[t][1].start = Object.assign({}, l.end), c = [], e[r][1].end.offset - e[r][1].start.offset && (c = st(c, [
["enter", e[r][1], n],
["exit", e[r][1], n]
])), c = st(c, [
["enter", i, n],
["enter", o, n],
["exit", o, n],
["enter", a, n]
]), c = st(
c,
Ja(
n.parser.constructs.insideSpan.null,
e.slice(r + 1, t),
n
)
), c = st(c, [
["exit", a, n],
["enter", l, n],
["exit", l, n],
["exit", i, n]
]), e[t][1].end.offset - e[t][1].start.offset ? (u = 2, c = st(c, [
["enter", e[t][1], n],
["exit", e[t][1], n]
])) : u = 0, xt(e, r - 1, t - r + 3, c), t = r + c.length - u - 2;
break;
}
}
for (t = -1; ++t < e.length; )
e[t][1].type === "attentionSequence" && (e[t][1].type = "data");
return e;
}
function ym(e, n) {
const t = this.parser.constructs.attentionMarkers.null, r = this.previous, i = ll(r);
let a;
return o;
function o(s) {
return a = s, e.enter("attentionSequence"), l(s);
}
function l(s) {
if (s === a)
return e.consume(s), l;
const c = e.exit("attentionSequence"), u = ll(s), d = !u || u === 2 && i || t.includes(s), y = !i || i === 2 && u || t.includes(r);
return c._open = !!(a === 42 ? d : d && (i || !y)), c._close = !!(a === 42 ? y : y && (u || !d)), n(s);
}
}
function sl(e, n) {
e.column += n, e.offset += n, e._bufferIndex += n;
}
const Em = {
name: "autolink",
tokenize: vm
};
function vm(e, n, t) {
let r = 0;
return i;
function i(f) {
return e.enter("autolink"), e.enter("autolinkMarker"), e.consume(f), e.exit("autolinkMarker"), e.enter("autolinkProtocol"), a;
}
function a(f) {
return bt(f) ? (e.consume(f), o) : c(f);
}
function o(f) {
return f === 43 || f === 45 || f === 46 || gt(f) ? (r = 1, l(f)) : c(f);
}
function l(f) {
return f === 58 ? (e.consume(f), r = 0, s) : (f === 43 || f === 45 || f === 46 || gt(f)) && r++ < 32 ? (e.consume(f), l) : (r = 0, c(f));
}
function s(f) {
return f === 62 ? (e.exit("autolinkProtocol"), e.enter("autolinkMarker"), e.consume(f), e.exit("autolinkMarker"), e.exit("autolink"), n) : f === null || f === 32 || f === 60 || Aa(f) ? t(f) : (e.consume(f), s);
}
function c(f) {
return f