import { type Mutex } from '@livekit/mutex';
import { DisconnectReason, type OwnedParticipant, type ParticipantInfo, ParticipantKind, type ParticipantKindDetail } from '@livekit/rtc-ffi-bindings';
import { type TrackPublishOptions } from '@livekit/rtc-ffi-bindings';
import type { PathLike } from 'node:fs';
import { type ByteStreamOptions, ByteStreamWriter, TextStreamWriter } from './data_streams/index.js';
import { FfiHandle } from './ffi_client.js';
import { type PerformRpcParams, type RpcInterceptor, type RpcInvocationData } from './rpc.js';
import type { LocalTrack } from './track.js';
import type { RemoteTrackPublication, TrackPublication } from './track_publication.js';
import { LocalTrackPublication } from './track_publication.js';
import type { Transcription } from './transcription.js';
import type { ChatMessage } from './types.js';
export declare abstract class Participant {
    /** @internal */
    info: ParticipantInfo;
    /** @internal */
    ffi_handle: FfiHandle;
    trackPublications: Map<string, TrackPublication>;
    constructor(owned_info: OwnedParticipant);
    get sid(): string | undefined;
    get name(): string | undefined;
    get identity(): string;
    get metadata(): string;
    get attributes(): Record<string, string>;
    get kind(): ParticipantKind;
    get kindDetails(): ParticipantKindDetail[];
    get disconnectReason(): DisconnectReason | undefined;
}
export type DataPublishOptions = {
    /**
     * whether to send this as reliable or lossy.
     * For data that you need delivery guarantee (such as chat messages), use Reliable.
     * For data that should arrive as quickly as possible, but you are ok with dropped
     * packets, use Lossy.
     */
    reliable?: boolean;
    /**
     * the identities of participants who will receive the message, will be sent to every one if empty
     */
    destination_identities?: string[];
    /** the topic under which the message gets published */
    topic?: string;
};
export declare class LocalParticipant extends Participant {
    private rpcHandlers;
    private rpcInterceptors;
    private ffiEventLock;
    private disconnectSignal;
    private openStreamWriters;
    trackPublications: Map<string, LocalTrackPublication>;
    constructor(info: OwnedParticipant, ffiEventLock: Mutex, disconnectSignal: AbortSignal);
    publishData(data: Uint8Array, options: DataPublishOptions): Promise<void>;
    publishDtmf(code: number, digit: string): Promise<void>;
    publishTranscription(transcription: Transcription): Promise<void>;
    updateMetadata(metadata: string): Promise<void>;
    /**
     * Returns a `StreamWriter` instance that allows to write individual chunks of text to a stream.
     * Well suited for TTS and/or streaming LLM output. If you want to simply send a text then use sendText() instead
     */
    streamText(options?: {
        topic?: string;
        attributes?: Record<string, string>;
        destinationIdentities?: Array<string>;
        streamId?: string;
        senderIdentity?: string;
    }): Promise<TextStreamWriter>;
    sendText(text: string, options?: {
        topic?: string;
        attributes?: Record<string, string>;
        destinationIdentities?: Array<string>;
        streamId?: string;
        /**
         * Whether the payload may be compressed on the wire. Defaults to true;
         * compression is only applied when it actually reduces the payload size
         * and every recipient supports it.
         */
        compress?: boolean;
    }): Promise<import("./data_streams/types.js").BaseStreamInfo>;
    streamBytes(options?: {
        name?: string;
        topic?: string;
        attributes?: Record<string, string>;
        destinationIdentities?: Array<string>;
        streamId?: string;
        mimeType?: string;
        totalSize?: number;
    }): Promise<ByteStreamWriter>;
    /** Sends a file provided as PathLike to specified recipients */
    sendFile(path: PathLike, options?: ByteStreamOptions): Promise<void>;
    private textStreamWriterWrite;
    private textStreamWriterClose;
    private byteStreamWriterWrite;
    private byteStreamWriterClose;
    /**
     * Drops the native writers of any data streams that were opened but never
     * closed — a writer the caller abandoned, or one whose write failed. Their
     * handles would otherwise be held by the FFI server for the lifetime of the
     * process. The room is already gone at this point, so the handles are dropped
     * directly rather than closed: there is no end-of-stream left to deliver.
     *
     * @internal
     */
    disposeOpenStreamWriters(): void;
    /**
     * Sends a chat message to participants in the room
     *
     * @param text - The text content of the chat message.
     * @param destinationIdentities - An optional array of recipient identities to whom the message will be sent. If omitted, the message is broadcast to all participants.
     * @param senderIdentity - An optional identity of the sender. If omitted, the default sender identity is used.
     *
     */
    sendChatMessage(text: string, destinationIdentities?: Array<string>, senderIdentity?: string): Promise<ChatMessage>;
    /**
     * @experimental
     */
    editChatMessage(editText: string, originalMessage: ChatMessage, destinationIdentities?: Array<string>, senderIdentity?: string): Promise<ChatMessage>;
    updateName(name: string): Promise<void>;
    setAttributes(attributes: Record<string, string>): Promise<void>;
    publishTrack(track: LocalTrack, options: TrackPublishOptions): Promise<LocalTrackPublication>;
    unpublishTrack(trackSid: string, stopOnUnpublish?: boolean): Promise<void>;
    /**
     * Initiate an RPC call to a remote participant.
     * @param params - Parameters for initiating the RPC call, see {@link PerformRpcParams}
     * @returns A promise that resolves with the response payload or rejects with an error.
     * @throws Error on failure. Details in `message`.
     */
    performRpc({ destinationIdentity, method, payload, responseTimeout, }: PerformRpcParams): Promise<string>;
    private performRpcFfi;
    /**
     * Add an {@link RpcInterceptor} that wraps every RPC this participant performs or handles.
     * Interceptors run in the order they were added, the first being outermost. Adding the same
     * instance twice is a no-op.
     *
     * @param interceptor - The interceptor to add
     */
    addRpcInterceptor(interceptor: RpcInterceptor): void;
    /**
     * Remove a previously added {@link RpcInterceptor}. Calls already in flight keep the chain
     * they started with.
     *
     * @param interceptor - The interceptor to remove
     */
    removeRpcInterceptor(interceptor: RpcInterceptor): void;
    /**
     * Establishes the participant as a receiver for calls of the specified RPC method.
     * Will overwrite any existing callback for the same method.
     *
     * @param method - The name of the indicated RPC method
     * @param handler - Will be invoked when an RPC request for this method is received
     * @returns A promise that resolves when the method is successfully registered
     *
     * @example
     * ```typescript
     * room.localParticipant?.registerRpcMethod(
     *   'greet',
     *   async (data: RpcInvocationData) => {
     *     console.log(`Received greeting from ${data.callerIdentity}: ${data.payload}`);
     *     return `Hello, ${data.callerIdentity}!`;
     *   }
     * );
     * ```
     *
     * See {@link RpcInvocationData} for more details on invocation params.
     *
     * The handler should return a Promise that resolves to a string.
     * If unable to respond within `responseTimeout`, the request will result in an error on the caller's side.
     *
     * You may throw errors of type `RpcError` with a string `message` in the handler,
     * and they will be received on the caller's side with the message intact.
     * Other errors thrown in your handler will not be transmitted as-is, and will instead arrive to the caller as `1500` ("Application Error").
     */
    registerRpcMethod(method: string, handler: (data: RpcInvocationData) => Promise<string>): void;
    /**
     * Unregisters a previously registered RPC method.
     *
     * @param method - The name of the RPC method to unregister
     */
    unregisterRpcMethod(method: string): void;
    /** @internal */
    handleRpcMethodInvocation(invocationId: bigint, method: string, requestId: string, callerIdentity: string, payload: string, responseTimeout: number): Promise<void>;
    /** The innermost step of the incoming chain: run the registered handler, if any. */
    private invokeRpcHandler;
}
export declare class RemoteParticipant extends Participant {
    trackPublications: Map<string, RemoteTrackPublication>;
    constructor(owned_info: OwnedParticipant);
}
//# sourceMappingURL=participant.d.ts.map