import { Behaviour } from "./Component.js";
import { EventList } from "./EventList.js";
export declare const noVoip = "noVoip";
/**
 * [Voip](https://engine.needle.tools/docs/api/Voip) Voice over IP (VoIP) component for real-time audio communication between users.
 * Allows sending and receiving audio streams in networked rooms.
 *
 * **Requirements:**
 * - Active network connection (via {@link SyncedRoom} or manual connection)
 * - User permission for microphone access (requested automatically)
 * - HTTPS connection (required for WebRTC)
 *
 * **Features:**
 * - Automatic connection when joining rooms (`autoConnect`)
 * - Background audio support (`runInBackground`)
 * - Optional UI toggle button (`createMenuButton`)
 * - Mute/unmute control
 *
 * **Debug:** Use `?debugvoip` URL parameter or set `debug = true` for logging.
 * Press 'v' to toggle mute, 'c' to connect/disconnect when debugging.
 *
 * @example Enable VoIP in your scene
 * ```ts
 * const voip = myObject.addComponent(Voip);
 * voip.autoConnect = true;
 * voip.createMenuButton = true;
 *
 * // Manual control
 * voip.connect();    // Start sending your microphone
 * voip.disconnect(); // Stop sending your microphone
 * voip.setMuted(true); // Mute incoming audio (silence other users)
 * ```
 *
 * @summary Voice over IP for networked audio communication
 * @category Networking
 * @group Components
 * @see {@link SyncedRoom} for room management
 * @see {@link NetworkedStreams} for the underlying streaming
 * @see {@link ScreenCapture} for video streaming
 * @link https://engine.needle.tools/docs/networking.html
 */
export declare class Voip extends Behaviour {
    /** When enabled, VoIP will start when a room is joined or when this component is enabled while already in a room.
     * @default true
    */
    autoConnect: boolean;
    /**
     * When enabled, VoIP will stay connected even when the browser tab is not focused/active anymore.
     * @default true
     */
    runInBackground: boolean;
    /**
     * When enabled, a menu button will be created to allow the user to toggle VoIP on and off.
     */
    createMenuButton: boolean;
    /**
     * When enabled debug messages will be printed to the console. This is useful for debugging audio issues. You can also append ?debugvoip to the URL to enable this.
     */
    debug: boolean;
    private _volume;
    /**
     * Volume for incoming audio streams (0 = silent, 1 = full volume).
     * Changes apply immediately to all active incoming streams.
     */
    get volume(): number;
    set volume(val: number);
    /**
     * Get the incoming audio element for a specific user.
     * Use this to route audio through the Web Audio API for spatial audio, effects, or analysis.
     * @param userId The connection ID of the remote user
     * @returns The HTMLAudioElement for this user's stream, or undefined if not connected
     * @example
     * ```ts
     * const audioEl = voip.getAudioElement(userId);
     * if (audioEl) {
     *   const audioCtx = new AudioContext();
     *   const source = audioCtx.createMediaElementSource(audioEl);
     *   const panner = audioCtx.createPanner();
     *   source.connect(panner).connect(audioCtx.destination);
     * }
     * ```
     */
    getAudioElement(userId: string): HTMLAudioElement | undefined;
    /**
     * Get all active incoming audio streams as a Map of userId → HTMLAudioElement.
     * Useful for iterating over all connected voice users.
     */
    get incomingStreams(): ReadonlyMap<string, HTMLAudioElement>;
    /**
     * Normalized amplitude threshold for speaking detection (0–1). When a user's average
     * audio amplitude exceeds this, they are considered "speaking". Default is 0.1.
     */
    speakingThreshold: number;
    /**
     * Event fired when a user's speaking state changes.
     * Passes `{ userId: string, isSpeaking: boolean, volume: number }`.
     */
    onSpeakingChanged: EventList;
    private _speakingStates;
    private _analysers;
    private _sharedAudioContext?;
    private _lastSpeakingPollMs;
    private _net?;
    private _menubutton?;
    /** @internal */
    awake(): void;
    /** @internal */
    onEnable(): void;
    /** @internal */
    onDisable(): void;
    /** @internal */
    onDestroy(): void;
    /** Set via the mic button (e.g. when the websocket connection closes and rejoins but the user was muted before we don't want to enable VOIP again automatically) */
    private _allowSending;
    private _outputStream;
    private _connectInFlight?;
    /**
     * @returns true if the component is currently sending audio
     */
    get isSending(): boolean;
    /** Start sending audio. */
    connect(audioSource?: MediaTrackConstraints): Promise<boolean>;
    private _connectImpl;
    /** Stop sending audio (muting your own microphone) */
    disconnect(opts?: {
        remember: boolean;
    }): void;
    /**
     * Mute or unmute the audio you hear from other users (incoming streams).
     * This does NOT mute your own microphone — use {@link disconnect} to stop sending your microphone.
     */
    setMuted(mute: boolean): void;
    /**
     * Returns true if incoming audio is currently muted (you can't hear other users).
     * When there are no incoming streams, returns false.
     */
    get isMuted(): boolean;
    private updateButton;
    /** @deprecated */
    getFrequency(_userId: string | null): number | null;
    private getAudioStream;
    private onJoinedRoom;
    private onLeftRoom;
    private _incomingStreams;
    /** @internal */
    update(): void;
    private setupAnalyser;
    private cleanupAnalyser;
    private closeSharedAudioContext;
    private onReceiveStream;
    private onStreamEnded;
    private onEnabledChanged;
    private onVisibilityChanged;
}
