"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_SYSTEM_PROMPT_TEMPLATE = void 0;
exports.AIPrompt = AIPrompt;
exports.createDefaultSystemPromptBuilder = createDefaultSystemPromptBuilder;
function AIPrompt(templateParts, ...functions) {
    return [[...templateParts.raw], ...functions];
}
function createDefaultSystemPromptBuilder(entries, options) {
    return (templateParts, ...functions) => {
        const out = [];
        for (let i = 0; i < templateParts.length; i++) {
            const part = templateParts[i];
            out.push(part);
            const fn = functions[i];
            if (fn) {
                const result = typeof fn === 'function' ? fn(entries, options) : fn;
                if (typeof result === 'string') {
                    out.push(result);
                }
                if (Array.isArray(result)) {
                    // @ts-expect-error - we know that the result is an array of strings, but TS can't handle it (Type instantiation is excessively deep and possibly infinite.)
                    out.push(result.flat(Infinity).join('\n\n'));
                }
            }
        }
        return out.join('');
    };
}
exports.DEFAULT_SYSTEM_PROMPT_TEMPLATE = AIPrompt `Meta information provided by the user about the current page they are on:

${(entries, options) => entries.map((entry) => {
    const formatted = options.formatData(entry.data);
    return [`### ${entry.label}`, formatted];
})}
`;
//# sourceMappingURL=templateStrings.js.map
