"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildWorkerEventHookDraftPrompt = buildWorkerEventHookDraftPrompt;
const event_hook_draft_contract_1 = require("./event-hook-draft-contract");
const dedicated_prompt_support_1 = require("./dedicated-prompt-support");
const prompt_repair_1 = require("./prompt-repair");
const prompt_text_1 = require("./prompt-text");
const system_prompt_names_1 = require("./system-prompt-names");
function buildWorkerEventHookDraftPrompt(workerName, input, repairContext) {
    const contract = (0, event_hook_draft_contract_1.buildWorkerEventHookDraftContract)(input);
    return (0, dedicated_prompt_support_1.renderDedicatedPromptEnvelope)({
        preambleLines: (0, dedicated_prompt_support_1.renderDedicatedPromptHeader)({
            workerName,
            runDescription: "This is a dedicated event hook create run.",
            instructionLines: [
                prompt_text_1.PROMPT_TEXT.introInstructions,
                "Use the event-hook-create system prompt as the hook creation guide.",
                "Do not change registry metadata. The hook path, runner, and trigger tokens are fixed input.",
                (0, prompt_text_1.buildEventHookLanguageInstruction)(input.outputLanguage),
            ],
            systemPrompts: input.systemPrompts,
            systemPromptNames: system_prompt_names_1.EVENT_HOOK_CREATE_SYSTEM_PROMPT_NAMES,
        }),
        repairLines: repairContext
            ? (0, prompt_repair_1.renderEventHookDraftRepairSectionLines)(repairContext)
            : undefined,
        inputLines: [
            ...(0, dedicated_prompt_support_1.renderDedicatedPromptInputLines)({
                heading: "Event hook authoring input:",
                prompt: input.prompt,
                workspace: input,
            }),
            `- Operation: ${input.operation}`,
            `- Hook path: ${input.hook.path}`,
            `- Hook runner: ${input.hook.runner}`,
            `- Hook triggers: ${input.hook.on.join(", ") || prompt_text_1.PROMPT_TEXT.none}`,
            `- Runtime event JSON example (minified): ${JSON.stringify(input.sampleEvent)}`,
            ...(input.currentHook
                ? [
                    `- Current hook digest: ${input.currentHook.digest}`,
                    "- Current hook body:",
                    "```text",
                    input.currentHook.body,
                    "```",
                ]
                : []),
        ],
        contract: {
            heading: "Event hook draft contract:",
            rules: contract.rules,
            promptSchema: contract.promptSchema,
            example: contract.example,
        },
    });
}
