import { Injectable, inject } from '@angular/core';
import { RealtimeSessionFacade } from '../../../../core/realtime';
import { ScreenShareStartOptions } from '../../domain/constants/screen-share.constants';

@Injectable({ providedIn: 'root' })
export class ScreenShareFacade {
  readonly isScreenSharing = inject(RealtimeSessionFacade).isScreenSharing;
  readonly screenStream = inject(RealtimeSessionFacade).screenStream;
  readonly isScreenShareRemotePlaybackSuppressed = inject(RealtimeSessionFacade).isScreenShareRemotePlaybackSuppressed;
  readonly forceDefaultRemotePlaybackOutput = inject(RealtimeSessionFacade).forceDefaultRemotePlaybackOutput;
  readonly onRemoteStream = inject(RealtimeSessionFacade).onRemoteStream;
  readonly onPeerDisconnected = inject(RealtimeSessionFacade).onPeerDisconnected;

  private readonly realtime = inject(RealtimeSessionFacade);

  getRemoteScreenShareStream(peerId: string): MediaStream | null {
    return this.realtime.getRemoteScreenShareStream(peerId);
  }

  async startScreenShare(options: ScreenShareStartOptions): Promise<MediaStream> {
    return await this.realtime.startScreenShare(options);
  }

  stopScreenShare(): void {
    this.realtime.stopScreenShare();
  }

  syncRemoteScreenShareRequests(peerIds: string[], enabled: boolean): void {
    this.realtime.syncRemoteScreenShareRequests(peerIds, enabled);
  }
}
