import { isJsonObject, jsonClone } from './hub/types/json.js';
import { encodeMetadataPassthroughWithNative, extractMetadataPassthroughWithNative } from '../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
export function encodeMetadataPassthrough(parameters, options) {
    return encodeMetadataPassthroughWithNative(parameters, options.prefix, options.keys);
}
export function extractMetadataPassthrough(metadataField, options) {
    if (!metadataField || !isJsonObject(metadataField)) {
        return {};
    }
    const cloned = jsonClone(metadataField);
    const native = extractMetadataPassthroughWithNative(cloned, options.prefix, options.keys);
    const metadata = native.metadata && isJsonObject(native.metadata) ? native.metadata : undefined;
    const passthrough = native.passthrough && isJsonObject(native.passthrough)
        ? native.passthrough
        : undefined;
    return {
        metadata,
        passthrough
    };
}
