import { resolve as e } from "./chunk-pathe.M-eThtNZ.js";
var t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", n = new Uint8Array(64), r = new Uint8Array(128);
for (let e = 0; e < t.length; e++) {
	let i = t.charCodeAt(e);
	n[e] = i, r[i] = e;
}
var i = /^\s*at .*(?:\S:\d+|\(native\))/m, a = /^(?:eval@)?(?:\[native code\])?$/, o = Date.now().toString().length, s = RegExp(`vitest=\\d{${o}}`);
function c(e) {
	if (!e.includes(":")) return [e];
	let t = /(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/^\(|\)$/g, ""));
	if (!t) return [e];
	let n = t[1];
	if (n.startsWith("async ") && (n = n.slice(6)), n.startsWith("http:") || n.startsWith("https:")) {
		let e = new URL(n);
		e.searchParams.delete("import"), e.searchParams.delete("browserv"), n = e.pathname + e.hash + e.search;
	}
	if (n.startsWith("/@fs/")) {
		let e = /^\/@fs\/[a-zA-Z]:\//.test(n);
		n = n.slice(e ? 5 : 4);
	}
	return n.includes("vitest=") && (n = n.replace(s, "").replace(/[?&]$/, "")), [
		n,
		t[2] || void 0,
		t[3] || void 0
	];
}
function l(e) {
	let t = e.trim();
	if (a.test(t) || (t.includes(" > eval") && (t = t.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ":$1")), !t.includes("@"))) return null;
	let n = -1, r = "", i;
	for (let e = 0; e < t.length; e++) if (t[e] === "@") {
		let a = t.slice(e + 1);
		if (a.includes(":") && a.length >= 3) {
			n = e, r = a, i = e > 0 ? t.slice(0, e) : void 0;
			break;
		}
	}
	if (n === -1 || !r.includes(":") || r.length < 3) return null;
	let [o, s, l] = c(r);
	return !o || !s || !l ? null : {
		file: o,
		method: i || "",
		line: Number.parseInt(s),
		column: Number.parseInt(l)
	};
}
function u(e) {
	let t = e.trim();
	return i.test(t) ? d(t) : l(t);
}
function d(t) {
	let n = t.trim();
	if (!i.test(n)) return null;
	n.includes("(eval ") && (n = n.replace(/eval code/g, "eval").replace(/(\(eval at [^()]*)|(,.*$)/g, ""));
	let r = n.replace(/^\s+/, "").replace(/\(eval code/g, "(").replace(/^.*?\s+/, ""), a = r.match(/ (\(.+\)$)/);
	r = a ? r.replace(a[0], "") : r;
	let [o, s, l] = c(a ? a[1] : r), u = a && r || "", d = o && ["eval", "<anonymous>"].includes(o) ? void 0 : o;
	return !d || !s || !l ? null : (u.startsWith("async ") && (u = u.slice(6)), d.startsWith("file://") && (d = d.slice(7)), d = d.startsWith("node:") || d.startsWith("internal:") ? d : e(d), u &&= u.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, ""), {
		method: u,
		file: d,
		line: Number.parseInt(s),
		column: Number.parseInt(l)
	});
}
//#endregion
export { u as parseSingleStack };

//# sourceMappingURL=source-map.js.map