import { isUrl as e } from "./minurl.shared.js";
//#region ../../node_modules/vfile/lib/minurl.browser.js
function t(t) {
	if (typeof t == "string") t = new URL(t);
	else if (!e(t)) {
		let e = /* @__PURE__ */ TypeError("The \"path\" argument must be of type string or an instance of URL. Received `" + t + "`");
		throw e.code = "ERR_INVALID_ARG_TYPE", e;
	}
	if (t.protocol !== "file:") {
		let e = /* @__PURE__ */ TypeError("The URL must be of scheme file");
		throw e.code = "ERR_INVALID_URL_SCHEME", e;
	}
	return n(t);
}
function n(e) {
	if (e.hostname !== "") {
		let e = /* @__PURE__ */ TypeError("File URL host must be \"localhost\" or empty on darwin");
		throw e.code = "ERR_INVALID_FILE_URL_HOST", e;
	}
	let t = e.pathname, n = -1;
	for (; ++n < t.length;) if (t.codePointAt(n) === 37 && t.codePointAt(n + 1) === 50) {
		let e = t.codePointAt(n + 2);
		if (e === 70 || e === 102) {
			let e = /* @__PURE__ */ TypeError("File URL path must not include encoded / characters");
			throw e.code = "ERR_INVALID_FILE_URL_PATH", e;
		}
	}
	return decodeURIComponent(t);
}
//#endregion
export { t as urlToPath };
