import { extractOutputSegmentsWithNative, normalizeContentPartWithNative, normalizeMessageContentPartsWithNative } from '../../router/virtual-router/engine-selection/native-shared-conversion-semantics.js';
function assertOutputContentNormalizerNativeAvailable() {
    if (typeof extractOutputSegmentsWithNative !== 'function' ||
        typeof normalizeContentPartWithNative !== 'function' ||
        typeof normalizeMessageContentPartsWithNative !== 'function') {
        throw new Error('[output-content-normalizer] native bindings unavailable');
    }
}
export function extractOutputSegments(source, itemsKey = 'output') {
    assertOutputContentNormalizerNativeAvailable();
    return extractOutputSegmentsWithNative(source, itemsKey);
}
export function normalizeContentPart(part, reasoningCollector) {
    assertOutputContentNormalizerNativeAvailable();
    const normalized = normalizeContentPartWithNative(part, reasoningCollector);
    reasoningCollector.splice(0, reasoningCollector.length, ...normalized.reasoningCollector);
    return normalized.normalized;
}
export function normalizeMessageContentParts(parts, reasoningCollector) {
    assertOutputContentNormalizerNativeAvailable();
    const normalized = normalizeMessageContentPartsWithNative(parts, reasoningCollector ?? []);
    if (reasoningCollector) {
        reasoningCollector.splice(0, reasoningCollector.length, ...normalized.reasoningChunks);
    }
    return normalized;
}
