/**
 * CanonicalConflictOp — runtime-backed conflict op normalization.
 *
 * Converts raw op records into the concrete op classes conflict analysis
 * understands, with a legacy anchor only for malformed records that still
 * deserve diagnostics.
 *
 * @module domain/services/strand/CanonicalConflictOp
 */
import { normalizeRawOp } from "../OpNormalizer.js";
import BlobValue from "../../types/ops/BlobValue.js";
import EdgeAdd from "../../types/ops/EdgeAdd.js";
import EdgePropSet from "../../types/ops/EdgePropSet.js";
import EdgeRemove from "../../types/ops/EdgeRemove.js";
import NodeAdd from "../../types/ops/NodeAdd.js";
import NodePropSet from "../../types/ops/NodePropSet.js";
import NodeRemove from "../../types/ops/NodeRemove.js";
import ConflictOpAnchor, { receiptNameForRawType } from "./ConflictOpAnchor.js";
const CANONICAL_CONFLICT_OP_CLASSES = Object.freeze([
    NodeAdd,
    NodeRemove,
    EdgeAdd,
    EdgeRemove,
    NodePropSet,
    EdgePropSet,
    BlobValue,
]);
function isCanonicalConflictOp(value) {
    return CANONICAL_CONFLICT_OP_CLASSES.some((OpClass) => value instanceof OpClass);
}
export function normalizeConflictOp(rawOp) {
    const normalizedOp = normalizeRawOp(rawOp);
    return isCanonicalConflictOp(normalizedOp) ? normalizedOp : ConflictOpAnchor.from(rawOp);
}
export function receiptNameForOp(canonOp) {
    return receiptNameForRawType(canonOp.type) ?? canonOp.receiptName;
}
