package app.chanora.chanora_flutter

/**
 * Central registry of Flutter MethodChannel names used by the Android
 * platform code.
 *
 * Trace:
 * - SDD-106 (`AndroidPermissionRequester` — bridge event surface)
 * - SRS-209 (Android runtime permission UX)
 *
 * The channels declared here are the Kotlin-side contract only. The
 * Dart-side handlers that subscribe / dispatch on these channels are
 * deliberately out of scope for the Wave 2B-2 implementation slice and
 * are handed off to a follow-up task.
 */
internal object MethodChannels {
    /**
     * Channel for Android runtime-permission state events emitted by
     * [AndroidPermissionRequester]. The Kotlin side invokes
     * [METHOD_PERMISSION_STATE_CHANGED] whenever the resolved permission
     * state transitions.
     *
     * Trace: SDD-106 §5 (Bridge event surface), SRS-209.
     */
    const val ANDROID_PERMISSIONS: String = "app.chanora/android_permissions"

    /**
     * Method name invoked on [ANDROID_PERMISSIONS] when the resolved
     * permission state for a tracked Android runtime permission
     * changes. Arguments are a `Map<String, Any>` with keys:
     *   - "permission": String (Android permission constant, e.g.
     *     "android.permission.RECORD_AUDIO")
     *   - "state": String (one of "Granted", "Denied",
     *     "PermanentlyDenied")
     *
     * Trace: SDD-106 §5.
     */
    const val METHOD_PERMISSION_STATE_CHANGED: String = "permissionStateChanged"

    /**
     * Channel name for the Android back-intent bridge (Kotlin <-> Dart).
     *
     * The Dart side uses the matching constant `backIntentChannelName` in
     * `lib/services/back_intent_service.dart`; both must remain in sync.
     *
     * Trace: SDD-028 (BackIntentService), SAD-018. X-2 strict-review fix:
     * consolidated from BackIntentBridge.kt's previous private literal.
     */
    const val BACK_INTENT: String = "app.chanora/back_intent"

    /**
     * Method invoked on [BACK_INTENT] from Kotlin -> Dart when a system
     * back event fires. Payload: `{"kind": "system_back"}`.
     *
     * Trace: SDD-028 §1. X-2 strict-review fix.
     */
    const val METHOD_BACK_INTENT: String = "backIntent"

    /**
     * Method invoked on [BACK_INTENT] from Dart -> Kotlin when the Dart
     * side concludes the back event is unhandled at the root route and
     * the activity should finish.
     *
     * Trace: SDD-028 §1. X-2 strict-review fix.
     */
    const val METHOD_POP_TO_SYSTEM: String = "popToSystem"

    /**
     * Channel for Android audio lifecycle events (route changes,
     * interruptions, app lifecycle). Mirrors the iOS
     * `chanora/ios_audio_lifecycle` channel.
     *
     * Trace: SDD-111 (cross-platform mobile voice backend)
     */
    const val ANDROID_AUDIO_LIFECYCLE: String = "chanora/android_audio_lifecycle"

    const val AUDIO_OUTPUT: String = "app.audio_output"
    const val AUDIO_OUTPUT_EVENTS: String = "app.audio_output/events"
    const val METHOD_GET_OUTPUT_DEVICES: String = "getOutputDevices"
    const val METHOD_GET_COMMUNICATION_DEVICES: String = "getCommunicationDevices"
    const val METHOD_SET_COMMUNICATION_DEVICE: String = "setCommunicationDevice"
    const val METHOD_CLEAR_COMMUNICATION_DEVICE: String = "clearCommunicationDevice"
}
