/**
 * Op — abstract base class for all WARP operations.
 *
 * Provides runtime identity (`instanceof Op`), the `type` discriminator
 * field for serialization, and the five behavior methods that the
 * reducer dispatches via `instanceof`:
 *
 *   - validate()   — structural field-shape checks
 *   - mutate()     — CRDT mutation (in place)
 *   - outcome()    — pre-mutation receipt outcome
 *   - snapshot()   — pre-mutation alive/prop snapshot
 *   - accumulate() — post-mutation diff emission
 */
import PatchError from "../../errors/PatchError.js";
export default class Op {
    /** Operation type discriminator (matches wire format). */
    type;
    /** Bit flags indicating raw, canonical, or both. See OpScope.ts. */
    scope;
    constructor(type, scope) {
        if (new.target === Op) {
            throw new PatchError('Op is abstract — use a concrete subclass (NodeAdd, EdgeAdd, etc.)', {
                code: 'E_OP_ABSTRACT',
            });
        }
        if (typeof type !== 'string' || type.length === 0) {
            throw new PatchError('Op type must be a non-empty string', {
                code: 'E_OP_INVALID_TYPE',
            });
        }
        this.type = type;
        this.scope = scope;
    }
}
