"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sanitizeRepeatOnDaysForStorage = sanitizeRepeatOnDaysForStorage;
/**
 * `schedule_jobs.repeat_on_days` (jsonb): weekday integers 0 (Sunday) … 6 (Saturday).
 * Used only when repeat_unit is weekly; store null or omit for other recurrence types.
 */
function sanitizeRepeatOnDaysForStorage(value) {
    if (value === undefined || value === null) {
        return null;
    }
    if (!Array.isArray(value)) {
        throw new Error('repeatOnDays must be an array of weekday numbers (0–6)');
    }
    const normalized = value
        .map((entry) => (typeof entry === 'string' ? Number.parseInt(entry, 10) : Number(entry)))
        .filter((day) => Number.isInteger(day) && day >= 0 && day <= 6);
    return normalized.length > 0 ? normalized : null;
}
//# sourceMappingURL=scheduleJobRepeatOnDays.js.map