package com.humand.demo.modules.CallService

import android.util.Log

/**
 * Constants and enums for the CallService module.
 */
object CallConstants {
    private const val TAG = "CallService"

    object CallingState {
        const val IDLE = "idle"
        const val JOINING = "joining"
        const val JOINED = "joined"
        const val RECONNECTING = "reconnecting"
        const val RECONNECTING_FAILED = "reconnecting-failed"
    }

    object RNEvents {
        const val CALL_ACCEPT = "CALL_ACCEPT_EVENT"
        const val CALL_MUTE = "CALL_MUTE_EVENT"
        const val CALL_END = "CALL_END_EVENT"
        const val CALL_AUDIO_ACTIVATED = "CALL_AUDIO_ACTIVATED_EVENT"
        const val CALL_AUDIO_ROUTE_CHANGED = "CALL_AUDIO_ROUTE_CHANGED_EVENT"
        const val CALL_STATE_CHANGED = "CALL_STATE_CHANGED_EVENT"
        const val CALL_PARTICIPANTS_CHANGED = "CALL_PARTICIPANTS_CHANGED_EVENT"
        const val CALL_MEDIA_STATE_CHANGED = "CALL_MEDIA_STATE_CHANGED_EVENT"
        const val CALL_PIP_MODE_CHANGED = "CALL_PIP_MODE_CHANGED_EVENT"
        const val CALLS_MOBILE_CALL_STARTED = "CALLS_MOBILE_CALL_STARTED"
        const val CALLS_MOBILE_CALL_ACCEPTED = "CALLS_MOBILE_CALL_ACCEPTED"
        const val CALLS_MOBILE_CALL_REJECTED = "CALLS_MOBILE_CALL_REJECTED"
        const val CALLS_MOBILE_CALL_PARTICIPANT_JOINED = "CALLS_MOBILE_CALL_PARTICIPANT_JOINED"
        const val CALLS_MOBILE_CALL_ENDED = "CALLS_MOBILE_CALL_ENDED"
        const val CALLS_MOBILE_CALL_RINGING = "CALLS_MOBILE_CALL_RINGING"
    }

    object ObserverEndSource {
        const val LOCAL = "local"
        const val REMOTE = "remote"
        const val SYSTEM = "system"
        const val UNKNOWN = "unknown"
    }

    object ObserverEndReason {
        const val LOCAL_HANGUP = "local_hangup"
        const val REMOTE_HANGUP = "remote_hangup"
        const val REJECTED = "rejected"
        const val TIMEOUT = "timeout"
        const val CONNECTION_FAILED = "connection_failed"
        const val UNKNOWN = "unknown"
    }

    object ConnectionQuality {
        const val EXCELLENT = "excellent"
        const val GOOD = "good"
        const val POOR = "poor"
        const val UNKNOWN = "unknown"
    }

    object TrackType {
        const val VIDEO = "videoTrack"
        const val SCREEN_SHARE = "screenShareTrack"
    }

    object ScalingMode {
        const val FIT = "fit"
        const val FILL = "fill"
    }

    object CallType {
        const val DEFAULT = "default"
        const val LIVESTREAM = "livestream"
    }

    object Timeout {
        const val OUTGOING_CALL_MS = 60_000L
    }

    /**
     * Microphone is disabled by default when participant count >= this threshold.
     */
    const val MIC_DISABLED_PARTICIPANT_THRESHOLD = 6
}

fun callLog(message: String) {
    Log.d("CallManager", "[CallManager] $message")
}

fun apiLog(message: String) {
    Log.d("CallApiService", "[ApiService] $message")
}
