function formatText(text, prefix) {
    const trimmed = text.trim();
    if (!trimmed)
        return '';
    if (!prefix)
        return trimmed;
    const needsSpace = !prefix.endsWith(' ') && !prefix.endsWith('\n');
    return `${prefix}${needsSpace ? ' ' : ''}${trimmed}`;
}
export function dispatchReasoning(input, options) {
    const trimmed = typeof input === 'string' ? input.trim() : '';
    if (!trimmed.length) {
        return {};
    }
    const mode = options?.mode ?? 'channel';
    if (mode === 'drop') {
        return {};
    }
    if (mode === 'text') {
        return {
            appendToContent: formatText(trimmed, options?.prefix)
        };
    }
    return { channel: trimmed };
}
