const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.cjs');
const require_buffer_utils = require('../lib/buffer_utils.cjs');
const require_base64 = require('../lib/base64.cjs');

//#region ../../node_modules/jose/dist/webapi/util/base64url.js
function decode(input) {
	if (Uint8Array.fromBase64) return Uint8Array.fromBase64(typeof input === "string" ? input : require_buffer_utils.decoder.decode(input), { alphabet: "base64url" });
	let encoded = input;
	if (encoded instanceof Uint8Array) encoded = require_buffer_utils.decoder.decode(encoded);
	encoded = encoded.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, "");
	try {
		return require_base64.decodeBase64(encoded);
	} catch {
		throw new TypeError("The input to be decoded is not correctly encoded.");
	}
}

//#endregion
exports.decode = decode;
//# sourceMappingURL=base64url.cjs.map