/**
 * EdgePropSet — canonical edge property operation (internal only).
 * Lowered to PropSet on the wire.
 */
import Op from "./Op.js";
import { OP_SCOPE_CANONICAL } from "./OpScope.js";
import { assertNonEmptyString, assertNoReservedBytes } from "./validate.js";
import { encodeEdgeKey, encodeEdgePropKey } from "../../services/KeyCodec.js";
import { mutateProp, snapshotProp, accumulatePropDiff } from "./propHelpers.js";
import ReceiptBuilder from "../../services/ReceiptBuilder.js";
export default class EdgePropSet extends Op {
    receiptName = 'EdgePropSet';
    from;
    to;
    label;
    key;
    value; // nosemgrep: ts-no-unknown-outside-adapters -- 0025B
    constructor({ from, to, label, key, value }) {
        super('EdgePropSet', OP_SCOPE_CANONICAL);
        assertNonEmptyString(from, 'EdgePropSet', 'from');
        assertNonEmptyString(to, 'EdgePropSet', 'to');
        assertNonEmptyString(label, 'EdgePropSet', 'label');
        assertNonEmptyString(key, 'EdgePropSet', 'key');
        assertNoReservedBytes(from, 'EdgePropSet', 'from');
        assertNoReservedBytes(to, 'EdgePropSet', 'to');
        assertNoReservedBytes(label, 'EdgePropSet', 'label');
        assertNoReservedBytes(key, 'EdgePropSet', 'key');
        this.from = from;
        this.to = to;
        this.label = label;
        this.key = key;
        this.value = value;
        Object.freeze(this);
    }
    validate() { }
    mutate(state, eventId) {
        mutateProp(state, encodeEdgePropKey(this.from, this.to, this.label, this.key), eventId, this.value);
    }
    outcome(state, eventId) {
        return ReceiptBuilder.edgePropSetOutcome(state, { from: this.from, to: this.to, label: this.label, key: this.key }, eventId);
    }
    snapshot(state) {
        return snapshotProp(state, encodeEdgePropKey(this.from, this.to, this.label, this.key));
    }
    accumulate(diff, state, before) {
        accumulatePropDiff(diff, state, encodeEdgeKey(this.from, this.to, this.label), this.key, before);
    }
}
