import computeShardKey from "../../utils/shardKey.js";
import { CheckpointBasisFact } from "./CheckpointBasisFactBase.js";
import { eventSortKey, eventTransport, validateEventId, validateText, } from "./CheckpointBasisFactValidation.js";
export class CheckpointEdgeFact extends CheckpointBasisFact {
    kind = 'edge-fact';
    from;
    to;
    label;
    alive;
    eventId;
    constructor(options) {
        super();
        this.from = validateText(options.from, 'from');
        this.to = validateText(options.to, 'to');
        this.label = validateText(options.label, 'label');
        this.alive = options.alive;
        this.eventId = validateEventId(options.eventId);
        Object.freeze(this);
    }
    shardFamily() {
        return 'edge-fact';
    }
    shardPath() {
        return `edge_${computeShardKey(`${this.from}\0${this.to}\0${this.label}`)}.cbor`;
    }
    sortKey() {
        return `${this.from}:${this.to}:${this.label}:${eventSortKey(this.eventId)}`;
    }
    toTransport() {
        return {
            kind: this.kind,
            from: this.from,
            to: this.to,
            label: this.label,
            alive: this.alive,
            eventId: eventTransport(this.eventId),
        };
    }
}
