"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateFilterErrorRows = generateFilterErrorRows;
function generateFilterErrorRows(context) {
    const deltaTypeName = context.import.detectDelta.allModels.type.name;
    return `
import type { ${deltaTypeName} } from './detect-delta/models.detect-delta'

/**
 * Returns a new Delta with all 'errors' rows removed from each model.
 * Used when ignoreErrors is enabled to skip errored rows during execution.
 */
export function filterErrorRows(delta: ${deltaTypeName}): ${deltaTypeName} {
  const result: ${deltaTypeName} = {}

  for (const [key, items] of Object.entries(delta) as [keyof ${deltaTypeName}, ${deltaTypeName}[keyof ${deltaTypeName}]][]) {
    if (!items) continue
    const filtered = items.filter((item: { type: string }) => item.type !== 'errors')
    if (filtered.length > 0) {
      ;(result as Record<string, unknown>)[key] = filtered
    }
  }

  return result
}
`;
}
//# sourceMappingURL=filter-error-rows.generator.js.map