export const isBinaryContent = (part) => part.type === "image_url" || part.type === "input_audio" || part.type === "video_url";
export const isTextContent = (part) => part.type === "text";
export const partitionContentParts = (parts) => {
    return {
        textParts: parts.filter(isTextContent),
        binaryParts: parts.filter(isBinaryContent)
    };
};
export const formatMultimodalContent = (content, parts) => {
    const { textParts, binaryParts } = partitionContentParts(parts);
    let fullText = typeof content === "string" ? content : "";
    const currentParts = typeof content === "string" ? [] : content;
    if (textParts.length > 0) {
        const additionalText = textParts.map((f) => f.text).join("\n");
        if (typeof content === "string") {
            fullText += "\n" + additionalText;
        }
        else {
            currentParts.push({ type: "text", text: additionalText });
        }
    }
    if (binaryParts.length > 0) {
        if (typeof content === "string") {
            return [{ type: "text", text: fullText }, ...binaryParts];
        }
        else {
            return [...currentParts, ...binaryParts];
        }
    }
    return typeof content === "string" ? fullText : currentParts;
};
