import { normalizeApplyPatchText, looksLikePatch } from '../patch-text/normalize.js';
export function extractNormalizedPatch(value) {
    if (!value) {
        return {};
    }
    const normalized = normalizeApplyPatchText(value);
    const patchLike = looksLikePatch(value) || looksLikePatch(normalized);
    if (!patchLike) {
        return {};
    }
    if (!/^(?:\s*)\*\*\*\s*Begin Patch\b/m.test(normalized)) {
        return { failureReason: 'unsupported_patch_format' };
    }
    return { patchText: normalized };
}
