const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.js');
const require_assertString$1 = require('./util/assertString.js');
const require_merge$1 = require('./util/merge.js');
const require_isByteLength$1 = require('./isByteLength.js');
const require_isFQDN$1 = require('./isFQDN.js');
const require_isIP$1 = require('./isIP.js');

//#region ../../node_modules/.pnpm/validator@13.12.0/node_modules/validator/lib/isEmail.js
var require_isEmail = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/validator@13.12.0/node_modules/validator/lib/isEmail.js": ((exports, module) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.default = isEmail;
	var _assertString = _interopRequireDefault(require_assertString$1.require_assertString());
	var _isByteLength = _interopRequireDefault(require_isByteLength$1.require_isByteLength());
	var _isFQDN = _interopRequireDefault(require_isFQDN$1.require_isFQDN());
	var _isIP = _interopRequireDefault(require_isIP$1.require_isIP());
	var _merge = _interopRequireDefault(require_merge$1.require_merge());
	function _interopRequireDefault(obj) {
		return obj && obj.__esModule ? obj : { default: obj };
	}
	var default_email_options = {
		allow_display_name: false,
		allow_underscores: false,
		require_display_name: false,
		allow_utf8_local_part: true,
		require_tld: true,
		blacklisted_chars: "",
		ignore_max_length: false,
		host_blacklist: [],
		host_whitelist: []
	};
	var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i;
	var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
	var gmailUserPart = /^[a-z\d]+$/;
	var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
	var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
	var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;
	var defaultMaxEmailLength = 254;
	/**
	* Validate display name according to the RFC2822: https://tools.ietf.org/html/rfc2822#appendix-A.1.2
	* @param {String} display_name
	*/
	function validateDisplayName(display_name) {
		var display_name_without_quotes = display_name.replace(/^"(.+)"$/, "$1");
		if (!display_name_without_quotes.trim()) return false;
		if (/[\.";<>]/.test(display_name_without_quotes)) {
			if (display_name_without_quotes === display_name) return false;
			if (!(display_name_without_quotes.split("\"").length === display_name_without_quotes.split("\\\"").length)) return false;
		}
		return true;
	}
	function isEmail(str, options) {
		(0, _assertString.default)(str);
		options = (0, _merge.default)(options, default_email_options);
		if (options.require_display_name || options.allow_display_name) {
			var display_email = str.match(splitNameAddress);
			if (display_email) {
				var display_name = display_email[1];
				str = str.replace(display_name, "").replace(/(^<|>$)/g, "");
				if (display_name.endsWith(" ")) display_name = display_name.slice(0, -1);
				if (!validateDisplayName(display_name)) return false;
			} else if (options.require_display_name) return false;
		}
		if (!options.ignore_max_length && str.length > defaultMaxEmailLength) return false;
		var parts = str.split("@");
		var domain = parts.pop();
		var lower_domain = domain.toLowerCase();
		if (options.host_blacklist.includes(lower_domain)) return false;
		if (options.host_whitelist.length > 0 && !options.host_whitelist.includes(lower_domain)) return false;
		var user = parts.join("@");
		if (options.domain_specific_validation && (lower_domain === "gmail.com" || lower_domain === "googlemail.com")) {
			user = user.toLowerCase();
			var username = user.split("+")[0];
			if (!(0, _isByteLength.default)(username.replace(/\./g, ""), {
				min: 6,
				max: 30
			})) return false;
			var _user_parts = username.split(".");
			for (var i = 0; i < _user_parts.length; i++) if (!gmailUserPart.test(_user_parts[i])) return false;
		}
		if (options.ignore_max_length === false && (!(0, _isByteLength.default)(user, { max: 64 }) || !(0, _isByteLength.default)(domain, { max: 254 }))) return false;
		if (!(0, _isFQDN.default)(domain, {
			require_tld: options.require_tld,
			ignore_max_length: options.ignore_max_length,
			allow_underscores: options.allow_underscores
		})) {
			if (!options.allow_ip_domain) return false;
			if (!(0, _isIP.default)(domain)) {
				if (!domain.startsWith("[") || !domain.endsWith("]")) return false;
				var noBracketdomain = domain.slice(1, -1);
				if (noBracketdomain.length === 0 || !(0, _isIP.default)(noBracketdomain)) return false;
			}
		}
		if (user[0] === "\"") {
			user = user.slice(1, user.length - 1);
			return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user);
		}
		var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart;
		var user_parts = user.split(".");
		for (var _i = 0; _i < user_parts.length; _i++) if (!pattern.test(user_parts[_i])) return false;
		if (options.blacklisted_chars) {
			if (user.search(new RegExp("[".concat(options.blacklisted_chars, "]+"), "g")) !== -1) return false;
		}
		return true;
	}
	module.exports = exports.default;
	module.exports.default = exports.default;
}) });

//#endregion
Object.defineProperty(exports, 'default', {
  enumerable: true,
  get: function () {
    return require_isEmail();
  }
});