"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findSemanticPlaceholderContent = findSemanticPlaceholderContent;
exports.hasSemanticPlaceholderContent = hasSemanticPlaceholderContent;
const TEMPLATE_TOKEN_PATTERN = /{{\s*[A-Za-z0-9_]+\s*}}/;
const PLACEHOLDER_TASK_MARKER_PATTERN = /^(?:(?:[-*+]\s+)(?:\[\s\]\s+)?)?(?:TBD|TODO|PLACEHOLDER)(?:\s*(?:[:—–-])\s*.*)?[.!]?$/i;
const UNCHECKED_TASK_MARKER_PATTERN = /^[-*+]\s+\[\s\](?:\s+.*)?$/;
const PENDING_PLACEHOLDER_PATTERN = /^(?:(?:[-*+]\s+)(?:\[\s\]\s+)?)?pending[.!]?$/i;
const FENCED_CODE_MARKER_PATTERN = /^\s*(`{3,}|~{3,})/;
const INLINE_CODE_SPAN_PATTERN = /`+[^`\r\n]*`+/g;
const QUOTED_IDENTIFIER_PATTERN = /"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'/g;
const PLACEHOLDER_EXACT_VALUES = new Set([
    "Pending.",
    "Pending. This implementation summary is initialized as the stable execution artifact for the task.",
    "None yet.",
    "None yet. Populate this section when implementation begins.",
    "None yet. Populate this section when implementation begins and verify the intended task-scoped code changes landed.",
    "Pending review after implementation.",
    "None yet. Record validation plus any changed-file inspection used to confirm the intended edits landed without obvious errors, missing edits, or unintended drift.",
    "Not started. Expected scope is limited to this task's declared implementation seams.",
    "Residual risk remains until executable behavior and validation evidence are recorded.",
    "Residual risk remains until executable behavior, changed-file verification, and validation evidence are recorded.",
    "Pending. This reconciliation artifact is initialized as the default milestone review rollup path for completed task summaries.",
    "- Pending. Add completed task implementation summaries as milestone execution work finishes.",
    "Pending review after task implementation summaries are available.",
    "Pending review. Evaluate each milestone criterion against the completed task summary evidence under these canonical headings.",
    "None yet. Record out-of-scope follow-up work here if implementation or review surfaces it.",
    "Pending. Summarize targeted CLI validation evidence once milestone tasks complete.",
    "Pending. Add concrete next tasks here only if reconciliation identifies remaining work after review.",
    "None accepted yet.",
    "Pending milestone review.",
    "Pending milestone review. No completed task implementation summaries are available yet.",
    "Pending milestone review. Evidence has been refreshed, but milestone acceptance still requires explicit human review."
]);
function findSemanticPlaceholderContent(value) {
    const trimmed = value.trim();
    if (trimmed === "") {
        return [{ kind: "empty-content", line: 1, rawText: "" }];
    }
    const findings = [];
    let fencedCodeMarker = null;
    for (const [index, line] of trimmed.split(/\r?\n/).entries()) {
        const fenceMatch = line.match(FENCED_CODE_MARKER_PATTERN);
        if (fenceMatch !== null) {
            const marker = fenceMatch[1][0];
            fencedCodeMarker = fencedCodeMarker === null
                ? marker
                : fencedCodeMarker === marker
                    ? null
                    : fencedCodeMarker;
            continue;
        }
        if (fencedCodeMarker !== null) {
            continue;
        }
        const semanticLine = line.trim();
        const unbulletedLine = semanticLine.replace(/^[-*+]\s+/, "").trim();
        if (PLACEHOLDER_EXACT_VALUES.has(semanticLine)
            || PLACEHOLDER_EXACT_VALUES.has(unbulletedLine)) {
            findings.push({
                kind: "exact-sentinel",
                line: index + 1,
                rawText: semanticLine
            });
            continue;
        }
        const visibleLine = semanticLine
            .replace(INLINE_CODE_SPAN_PATTERN, "")
            .replace(QUOTED_IDENTIFIER_PATTERN, "")
            .trim();
        if (visibleLine === "") {
            continue;
        }
        const kind = TEMPLATE_TOKEN_PATTERN.test(visibleLine)
            ? "unresolved-template-token"
            : PLACEHOLDER_TASK_MARKER_PATTERN.test(visibleLine)
                ? "task-marker"
                : UNCHECKED_TASK_MARKER_PATTERN.test(visibleLine)
                    ? "unchecked-task"
                    : PENDING_PLACEHOLDER_PATTERN.test(visibleLine)
                        ? "pending-sentinel"
                        : null;
        if (kind !== null) {
            findings.push({
                kind,
                line: index + 1,
                rawText: semanticLine
            });
        }
    }
    return findings;
}
function hasSemanticPlaceholderContent(value) {
    return findSemanticPlaceholderContent(value).length > 0;
}
