<?php
// ============================================================
//  Mailchimp compatibility shim — Phase 2e
// ============================================================
//
//  Mailchimp has been removed from Buy Local Lowveld.
//  This file used to contain the full integration. It now contains:
//    - app_log()    : the generic logger (formerly mc_log)
//    - mc_log()     : alias kept for backwards compatibility
//    - mc_*()       : no-op stubs that quietly do nothing
//
//  All event triggers (welcome, payment received, cancellation, etc.)
//  will be replaced by the in-house transactional email system in
//  the next phase.
// ============================================================

require_once __DIR__ . '/db.php';

// app_log() is defined in db.php (foundational logger)

// ── Backwards-compatible alias for old code paths ──────────────
if (!function_exists('mc_log')) {
    function mc_log(string $msg): void { app_log($msg); }
}

// ── No-op stubs (Mailchimp removed) ────────────────────────────
if (!function_exists('mc_is_configured')) {
    function mc_is_configured(): bool { return false; }
}
if (!function_exists('mc_upsert_member')) {
    function mc_upsert_member(...$args): bool { return true; }
}
if (!function_exists('mc_set_exclusive_tag')) {
    function mc_set_exclusive_tag(...$args): bool { return true; }
}
if (!function_exists('mc_trigger_journey')) {
    function mc_trigger_journey(...$args): bool { return true; }
}
if (!function_exists('mc_sync_member_from_db')) {
    function mc_sync_member_from_db(...$args): bool { return true; }
}
if (!function_exists('mc_event_payment_received')) {
    function mc_event_payment_received(...$args): bool { return true; }
}
if (!function_exists('mc_event_renewal_reminder')) {
    function mc_event_renewal_reminder(...$args): bool { return true; }
}
if (!function_exists('mc_event_payment_overdue')) {
    function mc_event_payment_overdue(...$args): bool { return true; }
}
if (!function_exists('mc_event_cancelled')) {
    function mc_event_cancelled(...$args): bool { return true; }
}
if (!function_exists('mc_subscriber_hash')) {
    function mc_subscriber_hash(string $email): string { return md5(strtolower(trim($email))); }
}
if (!function_exists('mc_call')) {
    function mc_call(...$args): ?array { return null; }
}