/** * Merge server-hydrated messages with local rows that are not yet visible in * the GET response (in-flight send, outbox retry, failed, or read lag). */ import type { ChatMessage } from "../../../utils/globals"; /** Local rows still awaiting server ack or retry. */ export declare function isPendingLocalMessage(message: ChatMessage): boolean; /** Streaming placeholders must not survive a REST refresh — Ably / GET own them. */ export declare function isEphemeralLocalMessage(message: ChatMessage): boolean; /** * Decide whether a local row should be merged on top of a server GET when its * id is absent from the payload. */ export declare function shouldRetainLocalMessage(message: ChatMessage): boolean; /** Collapse duplicate ids in an array, preferring the furthest-along delivery state. */ export declare function dedupeMessagesById(messages: ChatMessage[]): ChatMessage[]; /** First occurrence wins — caller must pass server rows before local rows. */ export declare function dedupeMessagesPreservingOrder(messages: ChatMessage[]): ChatMessage[]; /** * Server history first, then retained local rows whose ids are absent from the * server payload. Output is chronologically sorted and id-deduplicated (server * wins on id collisions). */ export declare function mergeHydratedMessages(serverMessages: ChatMessage[], localMessages: ChatMessage[], channelId: string): ChatMessage[];