function isAnthropicLikeModel(model) {
    const normalized = model.toLowerCase();
    return normalized.includes('claude') || normalized.includes('haiku');
}
function imageToShortcutProxyMultimodalBlock(block, model) {
    if (isAnthropicLikeModel(model)) {
        return {
            source: {
                data: block.data,
                media_type: block.mimeType,
                type: 'base64'
            },
            type: 'image'
        };
    }
    // Normal Shortcut proxy non-Anthropic path: this is the existing LangChain
    // multimodal image block consumed by Shortcut invoke and helper LLM stream
    // calls.
    return {
        image_url: { url: `data:${block.mimeType};base64,${block.data}` },
        type: 'image_url'
    };
}
function documentToShortcutProxyMultimodalBlock(block, model) {
    if (isAnthropicLikeModel(model)) {
        return {
            source: {
                data: block.data,
                media_type: block.mimeType,
                type: 'base64'
            },
            type: 'document'
        };
    }
    // Normal Shortcut proxy non-Anthropic path: LangChain multimodal `media`
    // block for Gemini PDF input. This is not OpenAI Responses `input_file`.
    return {
        data: block.data,
        mime_type: block.mimeType,
        type: 'media'
    };
}
export function aiContentToShortcutProxyContent(content, model) {
    if (typeof content === 'string')
        return content;
    return content
        .filter((block) => block.type === 'text' || block.type === 'image' || block.type === 'document')
        .map((block) => block.type === 'text'
        ? { text: block.text, type: 'text' }
        : block.type === 'image'
            ? imageToShortcutProxyMultimodalBlock(block, model)
            : documentToShortcutProxyMultimodalBlock(block, model));
}
export function aiUserContentToAnthropicContent(content, modelInput) {
    if (typeof content === 'string')
        return content;
    const blocks = content.map((block) => {
        if (block.type === 'text') {
            return { text: block.text, type: 'text' };
        }
        return {
            source: {
                data: block.data,
                media_type: block.mimeType,
                type: 'base64'
            },
            type: block.type
        };
    });
    const filteredBlocks = modelInput.includes('image')
        ? blocks
        : blocks.filter((block) => block.type !== 'image');
    return filteredBlocks.filter((block) => {
        if (block.type === 'text')
            return block.text.trim().length > 0;
        return true;
    });
}
export function aiUserContentToOpenAIResponsesContent(content) {
    if (typeof content === 'string')
        return [{ text: content, type: 'input_text' }];
    return content.map((block) => {
        if (block.type === 'text') {
            return { text: block.text, type: 'input_text' };
        }
        if (block.type === 'image') {
            return {
                detail: 'auto',
                image_url: `data:${block.mimeType};base64,${block.data}`,
                type: 'input_image'
            };
        }
        // OpenAI Responses accepts PDFs as input_file data URLs.
        return {
            file_data: `data:${block.mimeType};base64,${block.data}`,
            filename: block.filename ?? 'document.pdf',
            type: 'input_file'
        };
    });
}
//# sourceMappingURL=ai-content.js.map