import { HttpContextToken } from '@angular/common/http';
import { inject } from '@angular/core';
import { OpenApiConfigService } from '@rxap/open-api';

const OPEN_API_OPERATION_ID = new HttpContextToken(() => '');
const OPEN_API_SERVER_ID = new HttpContextToken(() => '');
const OPEN_API_OPERATION = new HttpContextToken(() => '');

const injectOpenApiBaseUrlHttpInterceptorFn = (req, next) => {
    const serverId = req.context.get(OPEN_API_SERVER_ID);
    const openApiConfigService = inject(OpenApiConfigService);
    if (serverId) {
        const baseUrl = openApiConfigService.getBaseUrl(undefined, serverId);
        return next(req.clone({ url: baseUrl + req.url }));
    }
    return next(req);
};

function toHttpParams(record, include = []) {
    if (!record) {
        return undefined;
    }
    return Object.entries(record)
        .filter(([key]) => include.includes(key))
        .reduce((acc, [key, signal]) => ({
        ...acc,
        [key]: signal(),
    }), {});
}

// region 
// endregion

/**
 * Generated bundle index. Do not edit.
 */

export { OPEN_API_OPERATION, OPEN_API_OPERATION_ID, OPEN_API_SERVER_ID, injectOpenApiBaseUrlHttpInterceptorFn, toHttpParams };
//# sourceMappingURL=rxap-open-api-http-resource.mjs.map
