/**
 * Signal Channel Adapter
 *
 * Signal integration via signal-cli REST API.
 * Requires a running signal-cli-rest-api instance
 * (https://github.com/bbernhard/signal-cli-rest-api).
 *
 * Supports text messages, attachments, group messaging,
 * and message reactions via the REST API.
 */
import type { ChannelConfig, OutboundMessage, DeliveryResult } from '../index.js';
import { BaseChannel } from '../index.js';
/**
 * Signal-specific configuration
 */
export interface SignalConfig extends ChannelConfig {
    type: 'signal';
    /** signal-cli REST API base URL (default: http://localhost:8080) */
    apiUrl?: string;
    /** Phone number registered with signal-cli (with country code, e.g. +1234567890) */
    phoneNumber: string;
    /** Polling interval in ms for receiving messages (default: 2000) */
    pollInterval?: number;
    /** Trust all known identities (skip safety number verification) */
    trustAllIdentities?: boolean;
}
/**
 * Signal message from the REST API
 */
export interface SignalMessage {
    envelope: {
        source?: string;
        sourceNumber?: string;
        sourceName?: string;
        sourceUuid?: string;
        timestamp?: number;
        dataMessage?: {
            timestamp?: number;
            message?: string;
            expiresInSeconds?: number;
            groupInfo?: {
                groupId: string;
                type?: string;
            };
            attachments?: SignalAttachment[];
            quote?: {
                id: number;
                author: string;
                text: string;
            };
            reaction?: {
                emoji: string;
                targetAuthor: string;
                targetSentTimestamp: number;
                isRemove: boolean;
            };
            mentions?: Array<{
                start: number;
                length: number;
                uuid: string;
            }>;
        };
        typingMessage?: {
            action: 'STARTED' | 'STOPPED';
            timestamp: number;
            groupId?: string;
        };
        receiptMessage?: {
            type: 'DELIVERY' | 'READ';
            timestamps: number[];
        };
        syncMessage?: {
            sentMessage?: {
                destination?: string;
                timestamp?: number;
                message?: string;
                groupInfo?: {
                    groupId: string;
                };
            };
        };
    };
    account?: string;
}
/**
 * Signal attachment
 */
export interface SignalAttachment {
    contentType?: string;
    filename?: string;
    id?: string;
    size?: number;
    width?: number;
    height?: number;
    caption?: string;
    voiceNote?: boolean;
}
/**
 * Signal group info from the REST API
 */
export interface SignalGroup {
    id: string;
    name: string;
    description?: string;
    members: string[];
    admins?: string[];
    blocked?: boolean;
}
/**
 * Signal channel via signal-cli REST API
 */
export declare class SignalChannel extends BaseChannel {
    private pollTimer;
    private polling;
    private groupCache;
    private reconnectionManager;
    private consecutiveErrors;
    constructor(config: SignalConfig);
    private get signalConfig();
    private get apiBase();
    private get encodedNumber();
    /**
     * Make a request to the signal-cli REST API
     */
    private apiRequest;
    /**
     * Connect to Signal by verifying the phone number is registered
     * and starting the message polling loop
     */
    connect(): Promise<void>;
    /**
     * Disconnect: stop polling
     */
    disconnect(): Promise<void>;
    /**
     * Send a Signal message
     */
    send(message: OutboundMessage): Promise<DeliveryResult>;
    /**
     * Send a typing indicator
     */
    sendTyping(recipient: string): Promise<void>;
    /**
     * React to a message with an emoji
     */
    react(recipient: string, targetAuthor: string, timestamp: number, emoji: string): Promise<void>;
    /**
     * List groups the registered number is a member of
     */
    listGroups(): Promise<SignalGroup[]>;
    /**
     * Start the message polling loop with reconnection support
     */
    private startPolling;
    /**
     * Stop polling
     */
    private stopPolling;
    /**
     * Handle a received Signal message
     */
    private handleIncoming;
    /**
     * Convert Signal attachments to MessageAttachment format
     */
    private convertAttachments;
    /**
     * Determine content type from a Signal data message
     */
    private determineContentType;
    /**
     * Map MIME type to ContentType
     */
    private mimeToContentType;
    /**
     * Check if an ID looks like a Signal group ID (base64)
     */
    private isGroupId;
    /**
     * Pre-load groups into the cache
     */
    private loadGroups;
}
export default SignalChannel;
