export function buildInstructions({ base, overrides, }) {
    const lines = [];
    const override = overrides?.promptOverride?.trim();
    if (override) {
        lines.push(override);
    }
    else {
        const trimmedBase = base.trim();
        if (trimmedBase)
            lines.push(trimmedBase);
    }
    const requiredInstructions = overrides?.requiredInstructions ?? [];
    for (const instruction of requiredInstructions) {
        const trimmed = instruction.trim();
        if (trimmed)
            lines.push(trimmed);
    }
    const lengthInstruction = overrides?.lengthInstruction?.trim();
    if (lengthInstruction)
        lines.push(lengthInstruction);
    const languageInstruction = overrides?.languageInstruction?.trim();
    if (languageInstruction)
        lines.push(languageInstruction);
    return lines.join("\n");
}
export function buildTaggedPrompt({ instructions, context, content, }) {
    const escapeTaggedValue = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
    const safeInstructions = instructions.trim();
    const safeContext = escapeTaggedValue(context.trim());
    const safeContent = escapeTaggedValue(typeof content === "string" ? content : "");
    return `<instructions>\n${safeInstructions}\n</instructions>\n\n<context>\n${safeContext}\n</context>\n\n<content>\n${safeContent}\n</content>\n`;
}
//# sourceMappingURL=format.js.map