"use strict";
/* eslint-disable max-classes-per-file */
/* eslint-disable no-underscore-dangle */
// eslint-disable-next-line max-classes-per-file
Object.defineProperty(exports, "__esModule", { value: true });
exports.DyteSelfParticipant = exports.DyteParticipant = void 0;
const react_native_1 = require("react-native");
const { DyteHelper } = react_native_1.NativeModules;
class DyteParticipant {
    constructor(hook) {
        this.metadata = {
            view_type: '',
            preset_name: '',
        };
        this._overlayHook = hook;
    }
    _update(peer, hook) {
        this.id = peer.id;
        this.name = peer.displayName;
        this.picture = peer.picture;
        this.isMe = peer.isMe;
        this.isPinned = peer.isPinned;
        this.videoTrack = peer.videoTrack;
        this.audioTrack = peer.audioTrack;
        this.videoEnabled = peer.videoVisible;
        this.audioEnabled = !peer.audioMuted;
        this.clientSpecificId = peer.clientSpecificId;
        this._participantHook = hook;
        this.metadata = peer.metadata;
    }
    sendMessage(message) {
        if (this._sendMessage) {
            this._sendMessage(message);
        }
    }
    disableAudio() {
        if (this._participantHook && this.audioEnabled) {
            this._participantHook.disablePeerAudio(this.id);
        }
    }
    disableVideo() {
        if (this._participantHook && this.videoEnabled) {
            this._participantHook.disablePeerVideo(this.id);
        }
    }
    pin() {
        if (this._participantHook) {
            this._participantHook.pin(this.id);
        }
    }
    unpin() {
        if (this._participantHook) {
            this._participantHook.unpin(this.id);
        }
    }
    setOverlay(element) {
        this._overlayHook(this.id, element);
    }
    updatePreset(presetName) {
        if (this._participantHook) {
            this._participantHook.updatePreset(this.id, presetName);
        }
    }
    setLabel(label) {
        if (this._participantHook) {
            this._participantHook.setLabel(this.id, label);
        }
    }
}
exports.DyteParticipant = DyteParticipant;
class DyteSelfParticipant {
    constructor(hook) {
        this.metadata = {
            view_type: '',
            preset_name: '',
        };
        this._overlayHook = hook;
    }
    _update(peer, hook) {
        this.id = peer.id;
        this.name = peer.displayName;
        this.picture = peer.picture;
        this.isMe = peer.isMe;
        if (this.isPinned !== peer.isPinned) {
            DyteHelper.SDKSelfPin(peer.isPinned);
        }
        this.isPinned = peer.isPinned;
        this.videoTrack = peer.videoTrack;
        this.audioTrack = peer.audioTrack;
        if (this.videoEnabled !== peer.videoVisible) {
            DyteHelper.SDKSelfVideo(peer.videoVisible);
        }
        this.videoEnabled = peer.videoVisible;
        if (this.audioEnabled === peer.audioMuted) {
            DyteHelper.SDKSelfAudio(!peer.audioMuted);
        }
        this.audioEnabled = !peer.audioMuted;
        this.clientSpecificId = peer.clientSpecificId;
        if (this.isScreensharing !== peer.isScreensharing) {
            DyteHelper.SDKSelfScreenshare(!peer.isScreensharing);
        }
        this.isScreensharing = peer.isScreensharing;
        this._participantHook = hook;
        this.isPresenting = !peer.webinarHiddenParticipant;
        this.metadata = peer.metadata;
    }
    enableAudio() {
        if (this._participantHook && !this.audioEnabled) {
            this._participantHook.toggleSelfAudio(this.id);
        }
    }
    enableVideo() {
        if (this._participantHook && !this.videoEnabled) {
            this._participantHook.toggleSelfVideo(this.id);
        }
    }
    disableAudio() {
        if (this._participantHook && this.audioEnabled) {
            this._participantHook.toggleSelfAudio(this.id);
        }
    }
    disableVideo() {
        if (this._participantHook && this.videoEnabled) {
            this._participantHook.toggleSelfVideo(this.id);
        }
    }
    enableScreenshare() {
        if (this._participantHook && !this.isScreensharing) {
            this._participantHook.enableScreenshare();
        }
    }
    disableScreenshare() {
        if (this._participantHook && this.isScreensharing) {
            this._participantHook.disableScreenshare();
        }
    }
    pin() {
        if (this._participantHook) {
            this._participantHook.pin(this.id);
        }
    }
    unpin() {
        if (this._participantHook) {
            this._participantHook.unpin(this.id);
        }
    }
    setOverlay(element, timeout) {
        this._overlayHook(this.id, element, timeout);
    }
    updatePreset(presetName) {
        if (this._participantHook) {
            this._participantHook.updatePreset(this.id, presetName);
        }
    }
}
exports.DyteSelfParticipant = DyteSelfParticipant;
//# sourceMappingURL=DyteParticipant.js.map