import * as Automerge from "@automerge/automerge";
export class PeerCrdtState {
    doc = Automerge.init();
    reset() {
        this.doc = Automerge.init();
    }
    applySyncMessage(message, format = "sync") {
        if (format === "snapshot") {
            this.doc = Automerge.load(message);
            return { view: this.doc };
        }
        if (format === "incremental") {
            this.doc = Automerge.loadIncremental(this.doc, message);
            return { view: this.doc };
        }
        const [nextDoc] = Automerge.receiveSyncMessage(this.doc, Automerge.initSyncState(), message);
        this.doc = nextDoc;
        return { view: this.doc };
    }
    getSnapshot() {
        return this.doc;
    }
}
//# sourceMappingURL=peer-crdt-state.js.map