import * as plugins from '../../plugins.js';
/**
 * Create a basic route context from connection information
 */
export function createBaseRouteContext(options) {
    return {
        ...options,
        timestamp: Date.now(),
    };
}
/**
 * Convert IHttpRouteContext to IRouteContext
 * This is used to ensure type compatibility when passing HTTP-specific context
 * to methods that require the base IRouteContext type
 */
export function toBaseContext(httpContext) {
    // Create a new object with only the properties from IRouteContext
    const baseContext = {
        port: httpContext.port,
        domain: httpContext.domain,
        clientIp: httpContext.clientIp,
        serverIp: httpContext.serverIp,
        path: httpContext.path,
        query: httpContext.query,
        headers: httpContext.headers,
        isTls: httpContext.isTls,
        tlsVersion: httpContext.tlsVersion,
        routeName: httpContext.routeName,
        routeId: httpContext.routeId,
        timestamp: httpContext.timestamp,
        connectionId: httpContext.connectionId
    };
    // Only copy targetHost if it's a string
    if (httpContext.targetHost) {
        baseContext.targetHost = httpContext.targetHost;
    }
    // Copy targetPort if it exists
    if (httpContext.targetPort) {
        baseContext.targetPort = httpContext.targetPort;
    }
    return baseContext;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm91dGUtY29udGV4dC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3RzL2NvcmUvbW9kZWxzL3JvdXRlLWNvbnRleHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSxrQkFBa0IsQ0FBQztBQTRENUM7O0dBRUc7QUFDSCxNQUFNLFVBQVUsc0JBQXNCLENBQUMsT0FRdEM7SUFDQyxPQUFPO1FBQ0wsR0FBRyxPQUFPO1FBQ1YsU0FBUyxFQUFFLElBQUksQ0FBQyxHQUFHLEVBQUU7S0FDdEIsQ0FBQztBQUNKLENBQUM7QUFFRDs7OztHQUlHO0FBQ0gsTUFBTSxVQUFVLGFBQWEsQ0FBQyxXQUE4QjtJQUMxRCxrRUFBa0U7SUFDbEUsTUFBTSxXQUFXLEdBQWtCO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