108 lines
3.5 KiB
JavaScript
108 lines
3.5 KiB
JavaScript
/*
|
|
* Extracted from browser-delivered Turbopack chunk: 4059424fbe7d8125.68eb83ea54.js
|
|
* Module id: 492940
|
|
* For reading/searching only; this factory depends on the original Turbopack runtime.
|
|
*/
|
|
|
|
const moduleFactory = (e, t, n) => {
|
|
"use strict";
|
|
let r =
|
|
/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,
|
|
i = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,
|
|
o = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,
|
|
a = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,
|
|
s = new Map([
|
|
["n", "\n"],
|
|
["r", "\r"],
|
|
["t", " "],
|
|
["b", "\b"],
|
|
["f", "\f"],
|
|
["v", "\v"],
|
|
["0", "\0"],
|
|
["\\", "\\"],
|
|
["e", "\x1b"],
|
|
["a", "\x07"],
|
|
]);
|
|
function l(e) {
|
|
let t = "u" === e[0],
|
|
n = "{" === e[1];
|
|
return (t && !n && 5 === e.length) || ("x" === e[0] && 3 === e.length)
|
|
? String.fromCharCode(parseInt(e.slice(1), 16))
|
|
: t && n
|
|
? String.fromCodePoint(parseInt(e.slice(2, -1), 16))
|
|
: s.get(e) || e;
|
|
}
|
|
function c(e, t) {
|
|
let n = {};
|
|
for (let e of t)
|
|
for (let t of e.styles) n[t[0]] = e.inverse ? null : t.slice(1);
|
|
let r = e;
|
|
for (let [e, t] of Object.entries(n))
|
|
if (Array.isArray(t)) {
|
|
if (!(e in r)) throw Error(`Unknown Chalk style: ${e}`);
|
|
r = t.length > 0 ? r[e](...t) : r[e];
|
|
}
|
|
return r;
|
|
}
|
|
t.exports = (e, t) => {
|
|
let n = [],
|
|
s = [],
|
|
u = [];
|
|
if (
|
|
(t.replace(r, (t, r, d, p, f, h) => {
|
|
if (r) u.push(l(r));
|
|
else if (p) {
|
|
let t = u.join("");
|
|
(u = []),
|
|
s.push(0 === n.length ? t : c(e, n)(t)),
|
|
n.push({
|
|
inverse: d,
|
|
styles: (function (e) {
|
|
let t;
|
|
i.lastIndex = 0;
|
|
let n = [];
|
|
for (; null !== (t = i.exec(e)); ) {
|
|
let e = t[1];
|
|
if (t[2]) {
|
|
let r = (function (e, t) {
|
|
let n,
|
|
r = [];
|
|
for (let i of t.trim().split(/\s*,\s*/g)) {
|
|
let t = Number(i);
|
|
if (Number.isNaN(t))
|
|
if ((n = i.match(o)))
|
|
r.push(
|
|
n[2].replace(a, (e, t, n) => (t ? l(t) : n)),
|
|
);
|
|
else
|
|
throw Error(
|
|
`Invalid Chalk template style argument: ${i} (in style '${e}')`,
|
|
);
|
|
else r.push(t);
|
|
}
|
|
return r;
|
|
})(e, t[2]);
|
|
n.push([e].concat(r));
|
|
} else n.push([e]);
|
|
}
|
|
return n;
|
|
})(p),
|
|
});
|
|
} else if (f) {
|
|
if (0 === n.length)
|
|
throw Error("Found extraneous } in Chalk template literal");
|
|
s.push(c(e, n)(u.join(""))), (u = []), n.pop();
|
|
} else u.push(h);
|
|
}),
|
|
s.push(u.join("")),
|
|
n.length > 0)
|
|
)
|
|
throw Error(
|
|
`Chalk template literal is missing ${n.length} closing bracket${1 === n.length ? "" : "s"} (\`}\`)`,
|
|
);
|
|
return s.join("");
|
|
};
|
|
};
|
|
|
|
export default moduleFactory;
|