Implement a function to deduplicate customer records by matching on multiple identifiers and returning the canonical profile at Acxiom.
The function receives a list of dictionaries. Records belong to the same group when they share a non-empty email, phone, or loyalty_id, directly or transitively. Return the earliest record from each group, preserving group order. Missing, empty, and null identifiers do not match other records.
Use the signature below. The input must not be modified.
def deduplicate_customers(records):