const brokenHistoricalReservationWrapper = /async function historicalReservationPreviewLegacy\(context,input\)\{const co=payrollTenant\(context,input\),data=await historicalReservationPreviewLegacy\(context,input\)[^\n]*\}\n?/g; export function normalizeHistoricalReservationPreviewBase(code) { let normalized = code.replace(brokenHistoricalReservationWrapper, ''); if (!normalized.includes('async function historicalReservationPreviewLegacy(context,input){')) { normalized = normalized.replace( 'async function historicalReservationPreview(context,input){', 'async function historicalReservationPreviewLegacy(context,input){', ); } const legacyCount = normalized.split('async function historicalReservationPreviewLegacy(context,input){').length - 1; if (legacyCount !== 1) throw new Error('历史预约预览基础函数版本不兼容'); return normalized; }