import { multiPlayersColor } from './color-picker.js';
export class RemoteColorManager {
    get awareness() {
        return this.host.page.workspace.awarenessStore;
    }
    get surfaceService() {
        return this.host.spec.getService('affine:surface');
    }
    constructor(host) {
        this.host = host;
        const sessionColor = this.surfaceService.editSession.getItem('remoteColor');
        if (sessionColor) {
            this.awareness.awareness.setLocalStateField('color', sessionColor);
            return;
        }
        const pickColor = multiPlayersColor.pick();
        this.awareness.awareness.setLocalStateField('color', pickColor);
        this.surfaceService.editSession.setItem('remoteColor', pickColor);
    }
    get(id) {
        const awarenessColor = this.awareness.getStates().get(id)?.color;
        if (awarenessColor) {
            return awarenessColor;
        }
        if (id !== this.awareness.awareness.clientID)
            return null;
        const sessionColor = this.surfaceService.editSession.getItem('remoteColor');
        if (sessionColor) {
            this.awareness.awareness.setLocalStateField('color', sessionColor);
            return sessionColor;
        }
        const pickColor = multiPlayersColor.pick();
        this.awareness.awareness.setLocalStateField('color', pickColor);
        this.surfaceService.editSession.setItem('remoteColor', pickColor);
        return pickColor;
    }
}
//# sourceMappingURL=remote-color-manager.js.map