UNPKG

@asafarim/simple-md-viewer

Version:

A professional markdown viewer with file tree navigation, directory content browsing, and advanced YAML front matter support

1,517 lines (1,514 loc) 1.29 MB
import Fe, { createContext as ky, useContext as qh, useEffect as ft, useState as Le, useMemo as Wu } from "react"; import { useNavigate as Gh, useParams as Ry, HashRouter as _y, Routes as Iy, Route as Cy } from "react-router-dom"; var Ln = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function Wt(e) { return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e; } var Nl = { exports: {} }, en = {}; /** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Yu; function xy() { if (Yu) return en; Yu = 1; var e = Fe, t = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, a = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 }; function o(s, l, u) { var d, c = {}, f = null, p = null; u !== void 0 && (f = "" + u), l.key !== void 0 && (f = "" + l.key), l.ref !== void 0 && (p = l.ref); for (d in l) r.call(l, d) && !i.hasOwnProperty(d) && (c[d] = l[d]); if (s && s.defaultProps) for (d in l = s.defaultProps, l) c[d] === void 0 && (c[d] = l[d]); return { $$typeof: t, type: s, key: f, ref: p, props: c, _owner: a.current }; } return en.Fragment = n, en.jsx = o, en.jsxs = o, en; } var tn = {}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Ku; function Ny() { return Ku || (Ku = 1, process.env.NODE_ENV !== "production" && function() { var e = Fe, t = Symbol.for("react.element"), n = Symbol.for("react.portal"), r = Symbol.for("react.fragment"), a = Symbol.for("react.strict_mode"), i = Symbol.for("react.profiler"), o = Symbol.for("react.provider"), s = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), u = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), c = Symbol.for("react.memo"), f = Symbol.for("react.lazy"), p = Symbol.for("react.offscreen"), h = Symbol.iterator, g = "@@iterator"; function E(k) { if (k === null || typeof k != "object") return null; var P = h && k[h] || k[g]; return typeof P == "function" ? P : null; } var T = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function S(k) { { for (var P = arguments.length, H = new Array(P > 1 ? P - 1 : 0), oe = 1; oe < P; oe++) H[oe - 1] = arguments[oe]; y("error", k, H); } } function y(k, P, H) { { var oe = T.ReactDebugCurrentFrame, he = oe.getStackAddendum(); he !== "" && (P += "%s", H = H.concat([he])); var Te = H.map(function(pe) { return String(pe); }); Te.unshift("Warning: " + P), Function.prototype.apply.call(console[k], console, Te); } } var R = !1, w = !1, v = !1, x = !1, C = !1, N; N = Symbol.for("react.module.reference"); function _(k) { return !!(typeof k == "string" || typeof k == "function" || k === r || k === i || C || k === a || k === u || k === d || x || k === p || R || w || v || typeof k == "object" && k !== null && (k.$$typeof === f || k.$$typeof === c || k.$$typeof === o || k.$$typeof === s || k.$$typeof === l || // This needs to include all possible module reference object // types supported by any Flight configuration anywhere since // we don't know which Flight build this will end up being used // with. k.$$typeof === N || k.getModuleId !== void 0)); } function O(k, P, H) { var oe = k.displayName; if (oe) return oe; var he = P.displayName || P.name || ""; return he !== "" ? H + "(" + he + ")" : H; } function F(k) { return k.displayName || "Context"; } function G(k) { if (k == null) return null; if (typeof k.tag == "number" && S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof k == "function") return k.displayName || k.name || null; if (typeof k == "string") return k; switch (k) { case r: return "Fragment"; case n: return "Portal"; case i: return "Profiler"; case a: return "StrictMode"; case u: return "Suspense"; case d: return "SuspenseList"; } if (typeof k == "object") switch (k.$$typeof) { case s: var P = k; return F(P) + ".Consumer"; case o: var H = k; return F(H._context) + ".Provider"; case l: return O(k, k.render, "ForwardRef"); case c: var oe = k.displayName || null; return oe !== null ? oe : G(k.type) || "Memo"; case f: { var he = k, Te = he._payload, pe = he._init; try { return G(pe(Te)); } catch { return null; } } } return null; } var W = Object.assign, j = 0, Z, ne, K, te, m, D, B; function b() { } b.__reactDisabledLog = !0; function M() { { if (j === 0) { Z = console.log, ne = console.info, K = console.warn, te = console.error, m = console.group, D = console.groupCollapsed, B = console.groupEnd; var k = { configurable: !0, enumerable: !0, value: b, writable: !0 }; Object.defineProperties(console, { info: k, log: k, warn: k, error: k, group: k, groupCollapsed: k, groupEnd: k }); } j++; } } function V() { { if (j--, j === 0) { var k = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: W({}, k, { value: Z }), info: W({}, k, { value: ne }), warn: W({}, k, { value: K }), error: W({}, k, { value: te }), group: W({}, k, { value: m }), groupCollapsed: W({}, k, { value: D }), groupEnd: W({}, k, { value: B }) }); } j < 0 && S("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var q = T.ReactCurrentDispatcher, Y; function J(k, P, H) { { if (Y === void 0) try { throw Error(); } catch (he) { var oe = he.stack.trim().match(/\n( *(at )?)/); Y = oe && oe[1] || ""; } return ` ` + Y + k; } } var ie = !1, re; { var ve = typeof WeakMap == "function" ? WeakMap : Map; re = new ve(); } function z(k, P) { if (!k || ie) return ""; { var H = re.get(k); if (H !== void 0) return H; } var oe; ie = !0; var he = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var Te; Te = q.current, q.current = null, M(); try { if (P) { var pe = function() { throw Error(); }; if (Object.defineProperty(pe.prototype, "props", { set: function() { throw Error(); } }), typeof Reflect == "object" && Reflect.construct) { try { Reflect.construct(pe, []); } catch (ze) { oe = ze; } Reflect.construct(k, [], pe); } else { try { pe.call(); } catch (ze) { oe = ze; } k.call(pe.prototype); } } else { try { throw Error(); } catch (ze) { oe = ze; } k(); } } catch (ze) { if (ze && oe && typeof ze.stack == "string") { for (var de = ze.stack.split(` `), Be = oe.stack.split(` `), _e = de.length - 1, Ce = Be.length - 1; _e >= 1 && Ce >= 0 && de[_e] !== Be[Ce]; ) Ce--; for (; _e >= 1 && Ce >= 0; _e--, Ce--) if (de[_e] !== Be[Ce]) { if (_e !== 1 || Ce !== 1) do if (_e--, Ce--, Ce < 0 || de[_e] !== Be[Ce]) { var et = ` ` + de[_e].replace(" at new ", " at "); return k.displayName && et.includes("<anonymous>") && (et = et.replace("<anonymous>", k.displayName)), typeof k == "function" && re.set(k, et), et; } while (_e >= 1 && Ce >= 0); break; } } } finally { ie = !1, q.current = Te, V(), Error.prepareStackTrace = he; } var Mt = k ? k.displayName || k.name : "", kt = Mt ? J(Mt) : ""; return typeof k == "function" && re.set(k, kt), kt; } function Ie(k, P, H) { return z(k, !1); } function X(k) { var P = k.prototype; return !!(P && P.isReactComponent); } function Ye(k, P, H) { if (k == null) return ""; if (typeof k == "function") return z(k, X(k)); if (typeof k == "string") return J(k); switch (k) { case u: return J("Suspense"); case d: return J("SuspenseList"); } if (typeof k == "object") switch (k.$$typeof) { case l: return Ie(k.render); case c: return Ye(k.type, P, H); case f: { var oe = k, he = oe._payload, Te = oe._init; try { return Ye(Te(he), P, H); } catch { } } } return ""; } var Ke = Object.prototype.hasOwnProperty, ht = {}, Zt = T.ReactDebugCurrentFrame; function Dt(k) { if (k) { var P = k._owner, H = Ye(k.type, k._source, P ? P.type : null); Zt.setExtraStackFrame(H); } else Zt.setExtraStackFrame(null); } function Sn(k, P, H, oe, he) { { var Te = Function.call.bind(Ke); for (var pe in k) if (Te(k, pe)) { var de = void 0; try { if (typeof k[pe] != "function") { var Be = Error((oe || "React class") + ": " + H + " type `" + pe + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof k[pe] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); throw Be.name = "Invariant Violation", Be; } de = k[pe](P, pe, oe, H, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (_e) { de = _e; } de && !(de instanceof Error) && (Dt(he), S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", oe || "React class", H, pe, typeof de), Dt(null)), de instanceof Error && !(de.message in ht) && (ht[de.message] = !0, Dt(he), S("Failed %s type: %s", H, de.message), Dt(null)); } } } var vn = Array.isArray; function Qt(k) { return vn(k); } function Qn(k) { { var P = typeof Symbol == "function" && Symbol.toStringTag, H = P && k[Symbol.toStringTag] || k.constructor.name || "Object"; return H; } } function Jn(k) { try { return Tn(k), !1; } catch { return !0; } } function Tn(k) { return "" + k; } function An(k) { if (Jn(k)) return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Qn(k)), Tn(k); } var L = T.ReactCurrentOwner, $ = { key: !0, ref: !0, __self: !0, __source: !0 }, ae, ge, me; me = {}; function Xe(k) { if (Ke.call(k, "ref")) { var P = Object.getOwnPropertyDescriptor(k, "ref").get; if (P && P.isReactWarning) return !1; } return k.ref !== void 0; } function lt(k) { if (Ke.call(k, "key")) { var P = Object.getOwnPropertyDescriptor(k, "key").get; if (P && P.isReactWarning) return !1; } return k.key !== void 0; } function ot(k, P) { if (typeof k.ref == "string" && L.current && P && L.current.stateNode !== P) { var H = G(L.current.type); me[H] || (S('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', G(L.current.type), k.ref), me[H] = !0); } } function At(k, P) { { var H = function() { ae || (ae = !0, S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", P)); }; H.isReactWarning = !0, Object.defineProperty(k, "key", { get: H, configurable: !0 }); } } function wt(k, P) { { var H = function() { ge || (ge = !0, S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", P)); }; H.isReactWarning = !0, Object.defineProperty(k, "ref", { get: H, configurable: !0 }); } } var Re = function(k, P, H, oe, he, Te, pe) { var de = { // This tag allows us to uniquely identify this as a React Element $$typeof: t, // Built-in properties that belong on the element type: k, key: P, ref: H, props: pe, // Record the component responsible for creating this element. _owner: Te }; return de._store = {}, Object.defineProperty(de._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: !1 }), Object.defineProperty(de, "_self", { configurable: !1, enumerable: !1, writable: !1, value: oe }), Object.defineProperty(de, "_source", { configurable: !1, enumerable: !1, writable: !1, value: he }), Object.freeze && (Object.freeze(de.props), Object.freeze(de)), de; }; function Jt(k, P, H, oe, he) { { var Te, pe = {}, de = null, Be = null; H !== void 0 && (An(H), de = "" + H), lt(P) && (An(P.key), de = "" + P.key), Xe(P) && (Be = P.ref, ot(P, he)); for (Te in P) Ke.call(P, Te) && !$.hasOwnProperty(Te) && (pe[Te] = P[Te]); if (k && k.defaultProps) { var _e = k.defaultProps; for (Te in _e) pe[Te] === void 0 && (pe[Te] = _e[Te]); } if (de || Be) { var Ce = typeof k == "function" ? k.displayName || k.name || "Unknown" : k; de && At(pe, Ce), Be && wt(pe, Ce); } return Re(k, de, Be, he, oe, L.current, pe); } } var Ze = T.ReactCurrentOwner, $u = T.ReactDebugCurrentFrame; function Ft(k) { if (k) { var P = k._owner, H = Ye(k.type, k._source, P ? P.type : null); $u.setExtraStackFrame(H); } else $u.setExtraStackFrame(null); } var er; er = !1; function tr(k) { return typeof k == "object" && k !== null && k.$$typeof === t; } function qu() { { if (Ze.current) { var k = G(Ze.current.type); if (k) return ` Check the render method of \`` + k + "`."; } return ""; } } function my(k) { { if (k !== void 0) { var P = k.fileName.replace(/^.*[\\\/]/, ""), H = k.lineNumber; return ` Check your code at ` + P + ":" + H + "."; } return ""; } } var Gu = {}; function hy(k) { { var P = qu(); if (!P) { var H = typeof k == "string" ? k : k.displayName || k.name; H && (P = ` Check the top-level render call using <` + H + ">."); } return P; } } function zu(k, P) { { if (!k._store || k._store.validated || k.key != null) return; k._store.validated = !0; var H = hy(P); if (Gu[H]) return; Gu[H] = !0; var oe = ""; k && k._owner && k._owner !== Ze.current && (oe = " It was passed a child from " + G(k._owner.type) + "."), Ft(k), S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', H, oe), Ft(null); } } function ju(k, P) { { if (typeof k != "object") return; if (Qt(k)) for (var H = 0; H < k.length; H++) { var oe = k[H]; tr(oe) && zu(oe, P); } else if (tr(k)) k._store && (k._store.validated = !0); else if (k) { var he = E(k); if (typeof he == "function" && he !== k.entries) for (var Te = he.call(k), pe; !(pe = Te.next()).done; ) tr(pe.value) && zu(pe.value, P); } } } function by(k) { { var P = k.type; if (P == null || typeof P == "string") return; var H; if (typeof P == "function") H = P.propTypes; else if (typeof P == "object" && (P.$$typeof === l || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. P.$$typeof === c)) H = P.propTypes; else return; if (H) { var oe = G(P); Sn(H, k.props, "prop", oe, k); } else if (P.PropTypes !== void 0 && !er) { er = !0; var he = G(P); S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", he || "Unknown"); } typeof P.getDefaultProps == "function" && !P.getDefaultProps.isReactClassApproved && S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function Ey(k) { { for (var P = Object.keys(k.props), H = 0; H < P.length; H++) { var oe = P[H]; if (oe !== "children" && oe !== "key") { Ft(k), S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", oe), Ft(null); break; } } k.ref !== null && (Ft(k), S("Invalid attribute `ref` supplied to `React.Fragment`."), Ft(null)); } } var Hu = {}; function Vu(k, P, H, oe, he, Te) { { var pe = _(k); if (!pe) { var de = ""; (k === void 0 || typeof k == "object" && k !== null && Object.keys(k).length === 0) && (de += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); var Be = my(he); Be ? de += Be : de += qu(); var _e; k === null ? _e = "null" : Qt(k) ? _e = "array" : k !== void 0 && k.$$typeof === t ? (_e = "<" + (G(k.type) || "Unknown") + " />", de = " Did you accidentally export a JSX literal instead of a component?") : _e = typeof k, S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", _e, de); } var Ce = Jt(k, P, H, he, Te); if (Ce == null) return Ce; if (pe) { var et = P.children; if (et !== void 0) if (oe) if (Qt(et)) { for (var Mt = 0; Mt < et.length; Mt++) ju(et[Mt], k); Object.freeze && Object.freeze(et); } else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); else ju(et, k); } if (Ke.call(P, "key")) { var kt = G(k), ze = Object.keys(P).filter(function(wy) { return wy !== "key"; }), nr = ze.length > 0 ? "{key: someKey, " + ze.join(": ..., ") + ": ...}" : "{key: someKey}"; if (!Hu[kt + nr]) { var Ay = ze.length > 0 ? "{" + ze.join(": ..., ") + ": ...}" : "{}"; S(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`, nr, kt, Ay, kt), Hu[kt + nr] = !0; } } return k === r ? Ey(Ce) : by(Ce), Ce; } } function yy(k, P, H) { return Vu(k, P, H, !0); } function Sy(k, P, H) { return Vu(k, P, H, !1); } var vy = Sy, Ty = yy; tn.Fragment = r, tn.jsx = vy, tn.jsxs = Ty; }()), tn; } process.env.NODE_ENV === "production" ? Nl.exports = xy() : Nl.exports = Ny(); var I = Nl.exports; const Xu = ["http", "https", "mailto", "tel"]; function Oy(e) { const t = (e || "").trim(), n = t.charAt(0); if (n === "#" || n === "/") return t; const r = t.indexOf(":"); if (r === -1) return t; let a = -1; for (; ++a < Xu.length; ) { const i = Xu[a]; if (r === i.length && t.slice(0, i.length).toLowerCase() === i) return t; } return a = t.indexOf("?"), a !== -1 && r > a || (a = t.indexOf("#"), a !== -1 && r > a) ? t : "javascript:void(0)"; } /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh <https://feross.org> * @license MIT */ var Ly = function(t) { return t != null && t.constructor != null && typeof t.constructor.isBuffer == "function" && t.constructor.isBuffer(t); }; const zh = /* @__PURE__ */ Wt(Ly); function ln(e) { return !e || typeof e != "object" ? "" : "position" in e || "type" in e ? Zu(e.position) : "start" in e || "end" in e ? Zu(e) : "line" in e || "column" in e ? Ol(e) : ""; } function Ol(e) { return Qu(e && e.line) + ":" + Qu(e && e.column); } function Zu(e) { return Ol(e && e.start) + "-" + Ol(e && e.end); } function Qu(e) { return e && typeof e == "number" ? e : 1; } class rt 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(t, n, r) { const a = [null, null]; let i = { // @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 n == "string" && (r = n, n = void 0), typeof r == "string") { const o = r.indexOf(":"); o === -1 ? a[1] = r : (a[0] = r.slice(0, o), a[1] = r.slice(o + 1)); } n && ("type" in n || "position" in n ? n.position && (i = n.position) : "start" in n || "end" in n ? i = n : ("line" in n || "column" in n) && (i.start = n)), this.name = ln(n) || "1:1", this.message = typeof t == "object" ? t.message : t, this.stack = "", typeof t == "object" && t.stack && (this.stack = t.stack), this.reason = this.message, this.fatal, this.line = i.start.line, this.column = i.start.column, this.position = i, this.source = a[0], this.ruleId = a[1], this.file, this.actual, this.expected, this.url, this.note; } } rt.prototype.file = ""; rt.prototype.name = ""; rt.prototype.reason = ""; rt.prototype.message = ""; rt.prototype.stack = ""; rt.prototype.fatal = null; rt.prototype.column = null; rt.prototype.line = null; rt.prototype.source = null; rt.prototype.ruleId = null; rt.prototype.position = null; const ut = { basename: Dy, dirname: Fy, extname: My, join: Py, sep: "/" }; function Dy(e, t) { if (t !== void 0 && typeof t != "string") throw new TypeError('"ext" argument must be a string'); mn(e); let n = 0, r = -1, a = e.length, i; if (t === void 0 || t.length === 0 || t.length > e.length) { for (; a--; ) if (e.charCodeAt(a) === 47) { if (i) { n = a + 1; break; } } else r < 0 && (i = !0, r = a + 1); return r < 0 ? "" : e.slice(n, r); } if (t === e) return ""; let o = -1, s = t.length - 1; for (; a--; ) if (e.charCodeAt(a) === 47) { if (i) { n = a + 1; break; } } else o < 0 && (i = !0, o = a + 1), s > -1 && (e.charCodeAt(a) === t.charCodeAt(s--) ? s < 0 && (r = a) : (s = -1, r = o)); return n === r ? r = o : r < 0 && (r = e.length), e.slice(n, r); } function Fy(e) { if (mn(e), e.length === 0) return "."; let t = -1, n = e.length, r; for (; --n; ) if (e.charCodeAt(n) === 47) { if (r) { t = n; break; } } else r || (r = !0); return t < 0 ? e.charCodeAt(0) === 47 ? "/" : "." : t === 1 && e.charCodeAt(0) === 47 ? "//" : e.slice(0, t); } function My(e) { mn(e); let t = e.length, n = -1, r = 0, a = -1, i = 0, o; for (; t--; ) { const s = e.charCodeAt(t); if (s === 47) { if (o) { r = t + 1; break; } continue; } n < 0 && (o = !0, n = t + 1), s === 46 ? a < 0 ? a = t : i !== 1 && (i = 1) : a > -1 && (i = -1); } return a < 0 || n < 0 || // We saw a non-dot character immediately before the dot. i === 0 || // The (right-most) trimmed path component is exactly `..`. i === 1 && a === n - 1 && a === r + 1 ? "" : e.slice(a, n); } function Py(...e) { let t = -1, n; for (; ++t < e.length; ) mn(e[t]), e[t] && (n = n === void 0 ? e[t] : n + "/" + e[t]); return n === void 0 ? "." : Uy(n); } function Uy(e) { mn(e); const t = e.charCodeAt(0) === 47; let n = By(e, !t); return n.length === 0 && !t && (n = "."), n.length > 0 && e.charCodeAt(e.length - 1) === 47 && (n += "/"), t ? "/" + n : n; } function By(e, t) { let n = "", r = 0, a = -1, i = 0, o = -1, s, l; for (; ++o <= e.length; ) { if (o < e.length) s = e.charCodeAt(o); else { if (s === 47) break; s = 47; } if (s === 47) { if (!(a === o - 1 || i === 1)) if (a !== o - 1 && i === 2) { if (n.length < 2 || r !== 2 || n.charCodeAt(n.length - 1) !== 46 || n.charCodeAt(n.length - 2) !== 46) { if (n.length > 2) { if (l = n.lastIndexOf("/"), l !== n.length - 1) { l < 0 ? (n = "", r = 0) : (n = n.slice(0, l), r = n.length - 1 - n.lastIndexOf("/")), a = o, i = 0; continue; } } else if (n.length > 0) { n = "", r = 0, a = o, i = 0; continue; } } t && (n = n.length > 0 ? n + "/.." : "..", r = 2); } else n.length > 0 ? n += "/" + e.slice(a + 1, o) : n = e.slice(a + 1, o), r = o - a - 1; a = o, i = 0; } else s === 46 && i > -1 ? i++ : i = -1; } return n; } function mn(e) { if (typeof e != "string") throw new TypeError( "Path must be a string. Received " + JSON.stringify(e) ); } const $y = { cwd: qy }; function qy() { return "/"; } function Ll(e) { return e !== null && typeof e == "object" && // @ts-expect-error: indexable. e.href && // @ts-expect-error: indexable. e.origin; } function Gy(e) { if (typeof e == "string") e = new URL(e); else if (!Ll(e)) { const t = new TypeError( 'The "path" argument must be of type string or an instance of URL. Received `' + e + "`" ); throw t.code = "ERR_INVALID_ARG_TYPE", t; } if (e.protocol !== "file:") { const t = new TypeError("The URL must be of scheme file"); throw t.code = "ERR_INVALID_URL_SCHEME", t; } return zy(e); } function zy(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 t = e.pathname; let n = -1; for (; ++n < t.length; ) if (t.charCodeAt(n) === 37 && t.charCodeAt(n + 1) === 50) { const r = t.charCodeAt(n + 2); if (r === 70 || r === 102) { const a = new TypeError( "File URL path must not include encoded / characters" ); throw a.code = "ERR_INVALID_FILE_URL_PATH", a; } } return decodeURIComponent(t); } const rr = ["history", "path", "basename", "stem", "extname", "dirname"]; class jh { /** * 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(t) { let n; t ? typeof t == "string" || jy(t) ? n = { value: t } : Ll(t) ? n = { path: t } : n = t : n = {}, this.data = {}, this.messages = [], this.history = [], this.cwd = $y.cwd(), this.value, this.stored, this.result, this.map; let r = -1; for (; ++r < rr.length; ) { const i = rr[r]; i in n && n[i] !== void 0 && n[i] !== null && (this[i] = i === "history" ? [...n[i]] : n[i]); } let a; for (a in n) rr.includes(a) || (this[a] = n[a]); } /** * 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(t) { Ll(t) && (t = Gy(t)), ir(t, "path"), this.path !== t && this.history.push(t); } /** * Get the parent path (example: `'~'`). */ get dirname() { return typeof this.path == "string" ? ut.dirname(this.path) : void 0; } /** * Set the parent path (example: `'~'`). * * Cannot be set if there’s no `path` yet. */ set dirname(t) { Ju(this.basename, "dirname"), this.path = ut.join(t || "", this.basename); } /** * Get the basename (including extname) (example: `'index.min.js'`). */ get basename() { return typeof this.path == "string" ? ut.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(t) { ir(t, "basename"), ar(t, "basename"), this.path = ut.join(this.dirname || "", t); } /** * Get the extname (including dot) (example: `'.js'`). */ get extname() { return typeof this.path == "string" ? ut.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(t) { if (ar(t, "extname"), Ju(this.dirname, "extname"), t) { if (t.charCodeAt(0) !== 46) throw new Error("`extname` must start with `.`"); if (t.includes(".", 1)) throw new Error("`extname` cannot contain multiple dots"); } this.path = ut.join(this.dirname, this.stem + (t || "")); } /** * Get the stem (basename w/o extname) (example: `'index.min'`). */ get stem() { return typeof this.path == "string" ? ut.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(t) { ir(t, "stem"), ar(t, "stem"), this.path = ut.join(this.dirname || "", t + (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(t) { return (this.value || "").toString(t || 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(t, n, r) { const a = new rt(t, n, r); return this.path && (a.name = this.path + ":" + a.name, a.file = this.path), a.fatal = !1, this.messages.push(a), a; } /** * 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(t, n, r) { const a = this.message(t, n, r); return a.fatal = null, a; } /** * 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(t, n, r) { const a = this.message(t, n, r); throw a.fatal = !0, a; } } function ar(e, t) { if (e && e.includes(ut.sep)) throw new Error( "`" + t + "` cannot be a path: did not expect `" + ut.sep + "`" ); } function ir(e, t) { if (!e) throw new Error("`" + t + "` cannot be empty"); } function Ju(e, t) { if (!e) throw new Error("Setting `" + t + "` requires `path` to be set too"); } function jy(e) { return zh(e); } function ec(e) { if (e) throw e; } var xn = Object.prototype.hasOwnProperty, Hh = Object.prototype.toString, tc = Object.defineProperty, nc = Object.getOwnPropertyDescriptor, rc = function(t) { return typeof Array.isArray == "function" ? Array.isArray(t) : Hh.call(t) === "[object Array]"; }, ac = function(t) { if (!t || Hh.call(t) !== "[object Object]") return !1; var n = xn.call(t, "constructor"), r = t.constructor && t.constructor.prototype && xn.call(t.constructor.prototype, "isPrototypeOf"); if (t.constructor && !n && !r) return !1; var a; for (a in t) ; return typeof a > "u" || xn.call(t, a); }, ic = function(t, n) { tc && n.name === "__proto__" ? tc(t, n.name, { enumerable: !0, configurable: !0, value: n.newValue, writable: !0 }) : t[n.name] = n.newValue; }, oc = function(t, n) { if (n === "__proto__") if (xn.call(t, n)) { if (nc) return nc(t, n).value; } else return; return t[n]; }, Hy = function e() { var t, n, r, a, i, o, s = arguments[0], l = 1, u = arguments.length, d = !1; for (typeof s == "boolean" && (d = s, s = arguments[1] || {}, l = 2), (s == null || typeof s != "object" && typeof s != "function") && (s = {}); l < u; ++l) if (t = arguments[l], t != null) for (n in t) r = oc(s, n), a = oc(t, n), s !== a && (d && a && (ac(a) || (i = rc(a))) ? (i ? (i = !1, o = r && rc(r) ? r : []) : o = r && ac(r) ? r : {}, ic(s, { name: n, newValue: e(d, o, a) })) : typeof a < "u" && ic(s, { name: n, newValue: a })); return s; }; const sc = /* @__PURE__ */ Wt(Hy); function Dl(e) { if (typeof e != "object" || e === null) return !1; const t = Object.getPrototypeOf(e); return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(Symbol.toStringTag in e) && !(Symbol.iterator in e); } function Vy() { const e = [], t = { run: n, use: r }; return t; function n(...a) { let i = -1; const o = a.pop(); if (typeof o != "function") throw new TypeError("Expected function as last argument, not " + o); s(null, ...a); function s(l, ...u) { const d = e[++i]; let c = -1; if (l) { o(l); return; } for (; ++c < a.length; ) (u[c] === null || u[c] === void 0) && (u[c] = a[c]); a = u, d ? Wy(d, s)(...u) : o(null, ...u); } } function r(a) { if (typeof a != "function") throw new TypeError( "Expected `middelware` to be a function, not " + a ); return e.push(a), t; } } function Wy(e, t) { let n; return r; function r(...o) { const s = e.length > o.length; let l; s && o.push(a); try { l = e.apply(this, o); } catch (u) { const d = ( /** @type {Error} */ u ); if (s && n) throw d; return a(d); } s || (l && l.then && typeof l.then == "function" ? l.then(i, a) : l instanceof Error ? a(l) : i(l)); } function a(o, ...s) { n || (n = !0, t(o, ...s)); } function i(o) { a(null, o); } } const Yy = Wh().freeze(), Vh = {}.hasOwnProperty; function Wh() { const e = Vy(), t = []; let n = {}, r, a = -1; return i.data = o, i.Parser = void 0, i.Compiler = void 0, i.freeze = s, i.attachers = t, i.use = l, i.parse = u, i.stringify = d, i.run = c, i.runSync = f, i.process = p, i.processSync = h, i; function i() { const g = Wh(); let E = -1; for (; ++E < t.length; ) g.use(...t[E]); return g.data(sc(!0, {}, n)), g; } function o(g, E) { return typeof g == "string" ? arguments.length === 2 ? (lr("data", r), n[g] = E, i) : Vh.call(n, g) && n[g] || null : g ? (lr("data", r), n = g, i) : n; } function s() { if (r) return i; for (; ++a < t.length; ) { const [g, ...E] = t[a]; if (E[0] === !1) continue; E[0] === !0 && (E[0] = void 0); const T = g.call(i, ...E); typeof T == "function" && e.use(T); } return r = !0, a = Number.POSITIVE_INFINITY, i; } function l(g, ...E) { let T; if (lr("use", r), g != null) if (typeof g == "function") w(g, ...E); else if (typeof g == "object") Array.isArray(g) ? R(g) : y(g); else throw new TypeError("Expected usable value, not `" + g + "`"); return T && (n.settings = Object.assign(n.settings || {}, T)), i; function S(v) { if (typeof v == "function") w(v); else if (typeof v == "object") if (Array.isArray(v)) { const [x, ...C] = v; w(x, ...C); } else y(v); else throw new TypeError("Expected usable value, not `" + v + "`"); } function y(v) { R(v.plugins), v.settings && (T = Object.assign(T || {}, v.settings)); } function R(v) { let x = -1; if (v != null) if (Array.isArray(v)) for (; ++x < v.length; ) { const C = v[x]; S(C); } else throw new TypeError("Expected a list of plugins, not `" + v + "`"); } function w(v, x) { let C = -1, N; for (; ++C < t.length; ) if (t[C][0] === v) { N = t[C]; break; } N ? (Dl(N[1]) && Dl(x) && (x = sc(!0, N[1], x)), N[1] = x) : t.push([...arguments]); } } function u(g) { i.freeze(); const E = nn(g), T = i.Parser; return or("parse", T), lc(T, "parse") ? new T(String(E), E).parse() : T(String(E), E); } function d(g, E) { i.freeze(); const T = nn(E), S = i.Compiler; return sr("stringify", S), uc(g), lc(S, "compile") ? new S(g, T).compile() : S(g, T); } function c(g, E, T) { if (uc(g), i.freeze(), !T && typeof E == "function" && (T = E, E = void 0), !T) return new Promise(S); S(null, T); function S(y, R) { e.run(g, nn(E), w); function w(v, x, C) { x = x || g, v ? R(v) : y ? y(x) : T(null, x, C); } } } function f(g, E) { let T, S; return i.run(g, E, y), cc("runSync", "run", S), T; function y(R, w) { ec(R), T = w, S = !0; } } function p(g, E) { if (i.freeze(), or("process", i.Parser), sr("process", i.Compiler), !E) return new Promise(T); T(null, E); function T(S, y) { const R = nn(g); i.run(i.parse(R), R, (v, x, C) => { if (v || !x || !C) w(v); else { const N = i.stringify(x, C); N == null || (Zy(N) ? C.value = N : C.result = N), w(v, C); } }); function w(v, x) { v || !x ? y(v) : S ? S(x) : E(null, x); } } } function h(g) { let E; i.freeze(), or("processSync", i.Parser), sr("processSync", i.Compiler); const T = nn(g); return i.process(T, S), cc("processSync", "process", E), T; function S(y) { E = !0, ec(y); } } } function lc(e, t) { 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 (Ky(e.prototype) || t in e.prototype); } function Ky(e) { let t; for (t in e) if (Vh.call(e, t)) return !0; return !1; } function or(e, t) { if (typeof t != "function") throw new TypeError("Cannot `" + e + "` without `Parser`"); } function sr(e, t) { if (typeof t != "function") throw new TypeError("Cannot `" + e + "` without `Compiler`"); } function lr(e, t) { if (t) throw new Error( "Cannot call `" + e + "` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`." ); } function uc(e) { if (!Dl(e) || typeof e.type != "string") throw new TypeError("Expected node, got `" + e + "`"); } function cc(e, t, n) { if (!n) throw new Error( "`" + e + "` finished async. Use `" + t + "` instead" ); } function nn(e) { return Xy(e) ? e : new jh(e); } function Xy(e) { return !!(e && typeof e == "object" && "message" in e && "messages" in e); } function Zy(e) { return typeof e == "string" || zh(e); } const Qy = {}; function Jy(e, t) { const n = t || Qy, r = typeof n.includeImageAlt == "boolean" ? n.includeImageAlt : !0, a = typeof n.includeHtml == "boolean" ? n.includeHtml : !0; return Yh(e, r, a); } function Yh(e, t, n) { if (eS(e)) { if ("value" in e) return e.type === "html" && !n ? "" : e.value; if (t && "alt" in e && e.alt) return e.alt; if ("children" in e) return dc(e.children, t, n); } return Array.isArray(e) ? dc(e, t, n) : ""; } function dc(e, t, n) { const r = []; let a = -1; for (; ++a < e.length; ) r[a] = Yh(e[a], t, n); return r.join(""); } function eS(e) { return !!(e && typeof e == "object"); } function Je(e, t, n, r) { const a = e.length; let i = 0, o; if (t < 0 ? t = -t > a ? 0 : a + t : t = t > a ? a : t, n = n > 0 ? n : 0, r.length < 1e4) o = Array.from(r), o.unshift(t, n), e.splice(...o); else for (n && e.splice(t, n); i < r.length; ) o = r.slice(i, i + 1e4), o.unshift(t, 0), e.splice(...o), i += 1e4, t += 1e4; } function nt(e, t) { return e.length > 0 ? (Je(e, e.length, 0, t), e) : t; } const pc = {}.hasOwnProperty; function Kh(e) { const t = {}; let n = -1; for (; ++n < e.length; ) tS(t, e[n]); return t; } function tS(e, t) { let n; for (n in t) { const a = (pc.call(e, n) ? e[n] : void 0) || (e[n] = {}), i = t[n]; let o; if (i) for (o in i) { pc.call(a, o) || (a[o] = []); const s = i[o]; nS( // @ts-expect-error Looks like a list. a[o], Array.isArray(s) ? s : s ? [s] : [] ); } } } function nS(e, t) { let n = -1; const r = []; for (; ++n < t.length; ) (t[n].add === "after" ? e : r).push(t[n]); Je(e, 0, 0, r); } const rS = /[!-\/:-@\[-`\{-~\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]/, qe = vt(/[A-Za-z]/), Pe = vt(/[\dA-Za-z]/), aS = vt(/[#-'*+\--9=?A-Z^-~]/); function Dn(e) { return ( // Special whitespace codes (which have negative values), C0 and Control // character DEL e !== null && (e < 32 || e === 127) ); } const Fl = vt(/\d/), iS = vt(/[\dA-Fa-f]/), oS = vt(/[!-/:-@[-`{-~]/); function ee(e) { return e !== null && e < -2; } function Ae(e) { return e !== null && (e < 0 || e === 32); } function ce(e) { return e === -2 || e === -1 || e === 32; } const Gn = vt(rS), xt = vt(/\s/); function vt(e) { return t; function t(n) { return n !== null && e.test(String.fromCharCode(n)); } } function fe(e, t, n, r) { const a = r ? r - 1 : Number.POSITIVE_INFINITY; let i = 0; return o; function o(l) { return ce(l) ? (e.enter(n), s(l)) : t(l); } function s(l) { return ce(l) && i++ < a ? (e.consume(l), s) : (e.exit(n), t(l)); } } const sS = { tokenize: lS }; function lS(e) { const t = e.attempt( this.parser.constructs.contentInitial, r, a ); let n; return t; function r(s) { if (s === null) { e.consume(s); return; } return e.enter("lineEnding"), e.consume(s), e.exit("lineEnding"), fe(e, t, "linePrefix"); } function a(s) { return e.enter("paragraph"), i(s); } functi