import buildUuid from "./uuid.js";
import { EdenEvents, fireEvent } from "./event.js";
import connectWebsocket, { disconnectWebsocket } from "./websocket/connect.js";
export function resolveCollaborationClientId(eden) {
    return eden.user?.email || buildUuid();
}
export function startCollaboration(eden) {
    eden.clientId = resolveCollaborationClientId(eden);
    connectWebsocket();
}
export function stopCollaboration(eden) {
    disconnectWebsocket();
    eden.players = [];
    fireEvent(document, EdenEvents.playersUpdated, {
        players: eden.players,
    });
}
