/**
 * HTTP types for routing module.
 * These were previously in http-proxy and are now self-contained here.
 */
import * as plugins from '../../plugins.js';
import { HttpStatus as ProtocolHttpStatus, getStatusText as getProtocolStatusText } from '../../protocols/http/index.js';
/**
 * HTTP-specific event types
 */
export var HttpEvents;
(function (HttpEvents) {
    HttpEvents["REQUEST_RECEIVED"] = "request-received";
    HttpEvents["REQUEST_FORWARDED"] = "request-forwarded";
    HttpEvents["REQUEST_HANDLED"] = "request-handled";
    HttpEvents["REQUEST_ERROR"] = "request-error";
})(HttpEvents || (HttpEvents = {}));
// Re-export for backward compatibility with subset of commonly used codes
export const HttpStatus = {
    OK: ProtocolHttpStatus.OK,
    MOVED_PERMANENTLY: ProtocolHttpStatus.MOVED_PERMANENTLY,
    FOUND: ProtocolHttpStatus.FOUND,
    TEMPORARY_REDIRECT: ProtocolHttpStatus.TEMPORARY_REDIRECT,
    PERMANENT_REDIRECT: ProtocolHttpStatus.PERMANENT_REDIRECT,
    BAD_REQUEST: ProtocolHttpStatus.BAD_REQUEST,
    UNAUTHORIZED: ProtocolHttpStatus.UNAUTHORIZED,
    FORBIDDEN: ProtocolHttpStatus.FORBIDDEN,
    NOT_FOUND: ProtocolHttpStatus.NOT_FOUND,
    METHOD_NOT_ALLOWED: ProtocolHttpStatus.METHOD_NOT_ALLOWED,
    REQUEST_TIMEOUT: ProtocolHttpStatus.REQUEST_TIMEOUT,
    TOO_MANY_REQUESTS: ProtocolHttpStatus.TOO_MANY_REQUESTS,
    INTERNAL_SERVER_ERROR: ProtocolHttpStatus.INTERNAL_SERVER_ERROR,
    NOT_IMPLEMENTED: ProtocolHttpStatus.NOT_IMPLEMENTED,
    BAD_GATEWAY: ProtocolHttpStatus.BAD_GATEWAY,
    SERVICE_UNAVAILABLE: ProtocolHttpStatus.SERVICE_UNAVAILABLE,
    GATEWAY_TIMEOUT: ProtocolHttpStatus.GATEWAY_TIMEOUT,
};
/**
 * Base error class for HTTP-related errors
 */
export class HttpError extends Error {
    statusCode;
    constructor(message, statusCode = HttpStatus.INTERNAL_SERVER_ERROR) {
        super(message);
        this.statusCode = statusCode;
        this.name = 'HttpError';
    }
}
/**
 * Error related to certificate operations
 */
export class CertificateError extends HttpError {
    domain;
    isRenewal;
    constructor(message, domain, isRenewal = false) {
        super(`${message} for domain ${domain}${isRenewal ? ' (renewal)' : ''}`, HttpStatus.INTERNAL_SERVER_ERROR);
        this.domain = domain;
        this.isRenewal = isRenewal;
        this.name = 'CertificateError';
    }
}
/**
 * Error related to server operations
 */
export class ServerError extends HttpError {
    code;
    constructor(message, code, statusCode = HttpStatus.INTERNAL_SERVER_ERROR) {
        super(message, statusCode);
        this.code = code;
        this.name = 'ServerError';
    }
}
/**
 * Error for bad requests
 */
export class BadRequestError extends HttpError {
    constructor(message) {
        super(message, HttpStatus.BAD_REQUEST);
        this.name = 'BadRequestError';
    }
}
/**
 * Error for not found resources
 */
export class NotFoundError extends HttpError {
    constructor(message = 'Resource not found') {
        super(message, HttpStatus.NOT_FOUND);
        this.name = 'NotFoundError';
    }
}
/**
 * Helper function to get HTTP status text
 */
export function getStatusText(status) {
    return getProtocolStatusText(status);
}
// Backward compatibility exports
export { HttpError as Port80HandlerError };
export { CertificateError as CertError };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC10eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3RzL3JvdXRpbmcvbW9kZWxzL2h0dHAtdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7OztHQUdHO0FBQ0gsT0FBTyxLQUFLLE9BQU8sTUFBTSxrQkFBa0IsQ0FBQztBQUM1QyxPQUFPLEVBQUUsVUFBVSxJQUFJLGtCQUFrQixFQUFFLGFBQWEsSUFBSSxxQkFBcUIsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBRXpIOztHQUVHO0FBQ0gsTUFBTSxDQUFOLElBQVksVUFLWDtB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