import { w as parseStrictPositiveInteger } from "./number-coercion-CLj0HTDM.js";
import { t as hasValidIsoCalendarComponents } from "./iso-time-Bkhu9DzU.js";
//#region src/cron/parse.ts
/** Parses cron schedule timestamps from user-facing absolute time strings. */
const ISO_TZ_RE = /(Z|[+-]\d{2}:?\d{2})$/i;
const ISO_DATE_RE = /^(?:[+-]\d{6}|\d{4})-\d{2}-\d{2}$/;
const ISO_DATE_TIME_RE = /^(?:[+-]\d{6}|\d{4})-\d{2}-\d{2}[Tt]/;
function normalizeUtcIso(raw) {
	if (ISO_TZ_RE.test(raw)) return raw;
	if (ISO_DATE_RE.test(raw)) return `${raw}T00:00:00Z`;
	if (ISO_DATE_TIME_RE.test(raw)) return `${raw}Z`;
	return raw;
}
/** Parses absolute cron timestamps from epoch milliseconds or ISO-like strings normalized to UTC. */
function parseAbsoluteTimeMs(input) {
	const raw = input.trim();
	if (!raw) return null;
	if (/^\d+$/.test(raw)) {
		const n = parseStrictPositiveInteger(raw);
		if (n !== void 0 && Number.isFinite(new Date(n).getTime())) return n;
		return null;
	}
	if (!hasValidIsoCalendarComponents(raw)) return null;
	const parsed = Date.parse(normalizeUtcIso(raw));
	return Number.isFinite(parsed) ? parsed : null;
}
//#endregion
export { parseAbsoluteTimeMs as t };
