/**
 * ConflictWinner — runtime-backed winner of a conflict trace.
 *
 * @module domain/types/conflict/ConflictWinner
 */
import WarpError from "../../errors/WarpError.js";
import ConflictAnchor from "./ConflictAnchor.js";
import { requireNonEmptyString } from "./validation.js";
const CTX = 'ConflictWinner';
/**
 * A runtime-backed winner record within a conflict trace.
 *
 * Instances are frozen on construction.
 */
export default class ConflictWinner {
    anchor;
    effectDigest;
    /**
     * Creates a frozen ConflictWinner.
     */
    constructor({ anchor, effectDigest }) {
        if (!(anchor instanceof ConflictAnchor)) {
            throw new WarpError(`${CTX}: anchor must be a ConflictAnchor instance`, 'E_VALIDATION');
        }
        this.anchor = anchor;
        this.effectDigest = requireNonEmptyString(effectDigest, 'effectDigest', CTX);
        Object.freeze(this);
    }
    /**
     * Creates a ConflictWinner from an OpRecord.
     */
    static fromRecord(record) {
        return new ConflictWinner({
            anchor: ConflictAnchor.fromRecord(record),
            effectDigest: record.effectDigest,
        });
    }
}
