import { n as __require, t as __commonJSMin } from "./chunk-CBBoxR_p.mjs";
//#region ../../node_modules/nodemailer/lib/errors.js
var require_errors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	/**
	* Nodemailer Error Codes
	*
	* Centralized error code definitions for consistent error handling.
	*
	* Usage:
	*   const errors = require('./errors');
	*   let err = new Error('Connection closed');
	*   err.code = errors.ECONNECTION;
	*/
	/**
	* Error code descriptions for documentation and debugging
	*/
	const ERROR_CODES = {
		ECONNECTION: "Connection closed unexpectedly",
		ETIMEDOUT: "Connection or operation timed out",
		ESOCKET: "Socket-level error",
		EDNS: "DNS resolution failed",
		ETLS: "TLS handshake or STARTTLS failed",
		EREQUIRETLS: "REQUIRETLS not supported by server (RFC 8689)",
		EPROTOCOL: "Invalid SMTP server response",
		EENVELOPE: "Invalid mail envelope (sender or recipients)",
		EMESSAGE: "Message delivery error",
		ESTREAM: "Stream processing error",
		EAUTH: "Authentication failed",
		ENOAUTH: "Authentication credentials not provided",
		EOAUTH2: "OAuth2 token generation or refresh error",
		EMAXLIMIT: "Pool resource limit reached (max messages per connection)",
		ESENDMAIL: "Sendmail command error",
		ESES: "AWS SES transport error",
		ECONFIG: "Invalid configuration",
		EPROXY: "Proxy connection error",
		EFILEACCESS: "File access rejected (disableFileAccess is set)",
		EURLACCESS: "URL access rejected (disableUrlAccess is set)",
		EFETCH: "HTTP fetch error"
	};
	module.exports = Object.keys(ERROR_CODES).reduce((exports$1, code) => {
		exports$1[code] = code;
		return exports$1;
	}, { ERROR_CODES });
}));
//#endregion
//#region ../../node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js
var require_http_proxy_client = /* @__PURE__ */ __commonJSMin(((exports, module) => {
	/**
	* Minimal HTTP/S proxy client
	*/
	const net = __require("net");
	const tls = __require("tls");
	const urllib = __require("url");
	const errors = require_errors();
	/**
	* Establishes proxied connection to destinationPort
	*
	* httpProxyClient("http://localhost:3128/", 80, "google.com", function(err, socket){
	*     socket.write("GET / HTTP/1.0\r\n\r\n");
	* });
	*
	* @param {String} proxyUrl proxy configuration, etg "http://proxy.host:3128/"
	* @param {Number} destinationPort Port to open in destination host
	* @param {String} destinationHost Destination hostname
	* @param {Function} callback Callback to run with the rocket object once connection is established
	*/
	function httpProxyClient(proxyUrl, destinationPort, destinationHost, callback) {
		let proxy = urllib.parse(proxyUrl);
		let options;
		let connect;
		let socket;
		options = {
			host: proxy.hostname,
			port: Number(proxy.port) ? Number(proxy.port) : proxy.protocol === "https:" ? 443 : 80
		};
		if (proxy.protocol === "https:") {
			options.rejectUnauthorized = false;
			connect = tls.connect.bind(tls);
		} else connect = net.connect.bind(net);
		let finished = false;
		let tempSocketErr = (err) => {
			if (finished) return;
			finished = true;
			try {
				socket.destroy();
			} catch (_E) {}
			callback(err);
		};
		let timeoutErr = () => {
			let err = /* @__PURE__ */ new Error("Proxy socket timed out");
			err.code = "ETIMEDOUT";
			tempSocketErr(err);
		};
		socket = connect(options, () => {
			if (finished) return;
			let reqHeaders = {
				Host: destinationHost + ":" + destinationPort,
				Connection: "close"
			};
			if (proxy.auth) reqHeaders["Proxy-Authorization"] = "Basic " + Buffer.from(proxy.auth).toString("base64");
			socket.write("CONNECT " + destinationHost + ":" + destinationPort + " HTTP/1.1\r\n" + Object.keys(reqHeaders).map((key) => key + ": " + reqHeaders[key]).join("\r\n") + "\r\n\r\n");
			let headers = "";
			let onSocketData = (chunk) => {
				let match;
				let remainder;
				if (finished) return;
				headers += chunk.toString("binary");
				if (match = headers.match(/\r\n\r\n/)) {
					socket.removeListener("data", onSocketData);
					remainder = headers.substr(match.index + match[0].length);
					headers = headers.substr(0, match.index);
					if (remainder) socket.unshift(Buffer.from(remainder, "binary"));
					finished = true;
					match = headers.match(/^HTTP\/\d+\.\d+ (\d+)/i);
					if (!match || (match[1] || "").charAt(0) !== "2") {
						try {
							socket.destroy();
						} catch (_E) {}
						let err = /* @__PURE__ */ new Error("Invalid response from proxy" + (match && ": " + match[1] || ""));
						err.code = errors.EPROXY;
						return callback(err);
					}
					socket.removeListener("error", tempSocketErr);
					socket.removeListener("timeout", timeoutErr);
					socket.setTimeout(0);
					return callback(null, socket);
				}
			};
			socket.on("data", onSocketData);
		});
		socket.setTimeout(httpProxyClient.timeout || 30 * 1e3);
		socket.on("timeout", timeoutErr);
		socket.once("error", tempSocketErr);
	}
	module.exports = httpProxyClient;
}));
//#endregion
export { require_errors as n, require_http_proxy_client as t };

//# sourceMappingURL=http-proxy-client-D2y0GXt6.mjs.map