package com.clanstop.healing.locator;

import java.util.List;
import java.util.Map;

/**
 * An immutable snapshot of a DOM element, captured on a successful find and used
 * to score candidates when the primary locator later breaks.
 *
 * <p>Serialised to/from JSONB via Selenium's bundled {@code org.openqa.selenium.json.Json},
 * so no extra JSON dependency is required.
 */
public record Fingerprint(
        String tag,
        String id,
        String name,
        List<String> classList,
        String visibleText,
        Map<String, String> attrs,
        String cssPath,
        String xpath,
        double centerX,
        double centerY,
        int domDepth
) {
    /** Attributes we consider stable enough to fingerprint on. */
    public static final List<String> TRACKED_ATTRS = List.of(
            "type", "placeholder", "aria-label", "data-testid", "role", "href", "alt", "title");
}
