// src/lib/policy.ts
var RETURN_POLICY_DAYS = 30;
var EXCHANGE_POLICY_DAYS = 30;
var CLAIM_POLICY_DAYS = 30;
var MS_PER_DAY = 1e3 * 60 * 60 * 24;
var getOrderDeliveredAt = (order) => {
  if (!order?.fulfillments?.length) {
    return null;
  }
  let latest = null;
  for (const f of order.fulfillments) {
    const delivered = f.delivered_at;
    if (!delivered) continue;
    const d = new Date(delivered);
    if (!latest || d > latest) {
      latest = d;
    }
  }
  return latest;
};
var isOutsidePolicyWindow = (order, days) => {
  const deliveredAt = getOrderDeliveredAt(order);
  if (!deliveredAt) {
    return false;
  }
  const elapsedMs = Date.now() - deliveredAt.getTime();
  return elapsedMs > days * MS_PER_DAY;
};

export {
  RETURN_POLICY_DAYS,
  EXCHANGE_POLICY_DAYS,
  CLAIM_POLICY_DAYS,
  isOutsidePolicyWindow
};
