// src/temporal-validity.ts
function effectiveValidAt(fm) {
  const explicit = fm.valid_at?.trim();
  if (explicit && explicit.length > 0) return explicit;
  return fm.created;
}
function effectiveInvalidAt(fm) {
  const explicit = fm.invalid_at?.trim();
  if (explicit && explicit.length > 0) return explicit;
  if (fm.status === "superseded") {
    const legacy = fm.supersededAt?.trim();
    if (legacy && legacy.length > 0) return legacy;
  }
  return void 0;
}
function isValidAsOf(fm, asOfMs) {
  if (!Number.isFinite(asOfMs)) return true;
  const validAtMs = Date.parse(effectiveValidAt(fm));
  if (!Number.isFinite(validAtMs)) return false;
  if (validAtMs > asOfMs) return false;
  const invalidAt = effectiveInvalidAt(fm);
  if (invalidAt === void 0) return true;
  const invalidAtMs = Date.parse(invalidAt);
  if (!Number.isFinite(invalidAtMs)) return true;
  return invalidAtMs > asOfMs;
}
function parseAsOfTimestamp(raw) {
  if (typeof raw !== "string" || raw.trim().length === 0) {
    throw new RangeError(
      `as_of must be a non-empty ISO 8601 timestamp string (got: ${typeof raw === "string" ? `"${raw}"` : typeof raw})`
    );
  }
  const ms = Date.parse(raw);
  if (!Number.isFinite(ms)) {
    throw new RangeError(
      `as_of must be a parseable ISO 8601 timestamp (got: "${raw}")`
    );
  }
  return ms;
}

export {
  effectiveValidAt,
  effectiveInvalidAt,
  isValidAsOf,
  parseAsOfTimestamp
};
//# sourceMappingURL=chunk-MDYG7VI7.js.map