import { ActorRefFrom, AnyActorRef, EventObject } from "xstate";
/** @internal */
declare const DOMAIN = "sanity/comlink";
/** @internal */
declare const RESPONSE_TIMEOUT_DEFAULT = 3000;
/** @internal */
declare const FETCH_TIMEOUT_DEFAULT = 10000;
/** @internal */
declare const HEARTBEAT_INTERVAL = 1000;
/** @internal */
declare const HANDSHAKE_INTERVAL = 500;
/**
 * @public
 */
declare const MSG_RESPONSE = "comlink/response";
/**
 * @public
 */
declare const MSG_HEARTBEAT = "comlink/heartbeat";
/** @internal */
declare const MSG_DISCONNECT = "comlink/disconnect";
/** @internal */
declare const MSG_HANDSHAKE_SYN = "comlink/handshake/syn";
/** @internal */
declare const MSG_HANDSHAKE_SYN_ACK = "comlink/handshake/syn-ack";
/** @internal */
declare const MSG_HANDSHAKE_ACK = "comlink/handshake/ack";
/** @internal */
declare const HANDSHAKE_MSG_TYPES: string[];
/** @internal */
declare const INTERNAL_MSG_TYPES: string[];
/**
 * @public
 */
type Status = 'idle' | 'handshaking' | 'connected' | 'disconnected';
/**
 * @public
 */
type StatusEvent = {
  connection: string;
  status: Status;
};
/**
 * @public
 */
type MessageType = string;
/**
 * @public
 */
type MessageData = Record<string, unknown> | undefined;
/**
 * @public
 */
interface Message {
  type: MessageType;
  data?: MessageData;
  response?: MessageData;
}
/**
 * @public
 */
interface RequestData<TSends extends Message> {
  data?: MessageData;
  expectResponse?: boolean;
  responseTo?: string;
  type: MessageType;
  resolvable?: PromiseWithResolvers<TSends['response']>;
  options?: {
    responseTimeout?: number;
    signal?: AbortSignal;
    suppressWarnings?: boolean;
  };
}
/**
 * @public
 */
type WithoutResponse<TMessage extends Message> = Omit<TMessage, 'response'>;
/**
 * @public
 */
interface ListenInput {
  count?: number;
  domain: string;
  exclude: string[];
  from: string;
  include: string[];
  responseType: string;
  target: MessageEventSource | undefined;
  to: string;
}
/**
 * @public
 */
interface BufferAddedEmitEvent<TMessage extends Message> {
  type: 'buffer.added';
  message: TMessage;
}
/**
 * @public
 */
interface BufferFlushedEmitEvent<TMessage extends Message> {
  type: 'buffer.flushed';
  messages: TMessage[];
}
/**
 * @public
 */
interface HeartbeatEmitEvent {
  type: 'heartbeat';
}
/**
 * @public
 */
interface StatusEmitEvent {
  type: 'status';
  status: Status;
}
type MessageEmitEvent<TMessage extends Message> = {
  type: 'message';
  message: ProtocolMessage<TMessage>;
};
/**
 * @public
 */
type InternalEmitEvent<TSends extends Message, TReceives extends Message> = BufferAddedEmitEvent<TSends> | BufferFlushedEmitEvent<TReceives> | MessageEmitEvent<TReceives> | StatusEmitEvent;
/**
 * @public
 */
type ProtocolMessage<TMessage extends Message = Message> = {
  id: string;
  channelId: string;
  data?: TMessage['data'];
  domain: string;
  from: string;
  responseTo?: string;
  to: string;
  type: TMessage['type'];
};
/**
 * @public
 */
interface ResponseMessage {
  type: typeof MSG_RESPONSE;
  data: MessageData;
}
/**
 * @public
 */
interface HeartbeatMessage {
  type: typeof MSG_HEARTBEAT;
  data: undefined;
}
/**
 * @internal
 */
interface DisconnectMessage {
  type: typeof MSG_DISCONNECT;
  data: undefined;
}
/**
 * @internal
 */
type HandshakeMessageType = typeof MSG_HANDSHAKE_ACK | typeof MSG_HANDSHAKE_SYN | typeof MSG_HANDSHAKE_SYN_ACK;
/**
 * @internal
 */
type InternalMessageType = typeof MSG_DISCONNECT | typeof MSG_HANDSHAKE_ACK | typeof MSG_HANDSHAKE_SYN | typeof MSG_HANDSHAKE_SYN_ACK | typeof MSG_HEARTBEAT | typeof MSG_RESPONSE;
/**
 * @public
 */
interface RequestMachineContext<TSends extends Message> {
  channelId: string;
  data: MessageData | undefined;
  domain: string;
  expectResponse: boolean;
  from: string;
  id: string;
  parentRef: AnyActorRef;
  resolvable: PromiseWithResolvers<TSends['response']> | undefined;
  response: TSends['response'] | null;
  responseTimeout: number | undefined;
  responseTo: string | undefined;
  signal: AbortSignal | undefined;
  suppressWarnings: boolean | undefined;
  sources: Set<MessageEventSource>;
  targetOrigin: string;
  to: string;
  type: MessageType;
}
/**
 * @public
 */
type RequestActorRef<TSends extends Message> = ActorRefFrom<ReturnType<typeof createRequestMachine<TSends>>>;
/**
 * @public
 */
declare const createRequestMachine: <TSends extends Message>() => import("xstate").StateMachine<RequestMachineContext<TSends>, {
  type: 'message';
  data: ProtocolMessage<ResponseMessage>;
} | {
  type: 'abort';
}, {
  "listen for response"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage<ResponseMessage>>, {
    requestId: string;
    sources: Set<MessageEventSource>;
    signal?: AbortSignal;
  }, import("xstate").EventObject>> | undefined;
}, {
  src: "listen";
  logic: import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage<ResponseMessage>>, {
    requestId: string;
    sources: Set<MessageEventSource>;
    signal?: AbortSignal;
  }, import("xstate").EventObject>;
  id: "listen for response";
}, {
  type: "on abort";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "on fail";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "on success";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "send message";
  params: {
    message: ProtocolMessage;
  };
}, {
  type: "expectsResponse";
  params: unknown;
}, "initialTimeout" | "responseTimeout", "aborted" | "awaiting" | "failed" | "idle" | "sending" | "success", string, {
  channelId: string;
  data?: TSends['data'];
  domain: string;
  expectResponse?: boolean;
  from: string;
  parentRef: AnyActorRef;
  resolvable?: PromiseWithResolvers<TSends['response']>;
  responseTimeout?: number;
  responseTo?: string;
  signal?: AbortSignal;
  sources: Set<MessageEventSource> | MessageEventSource;
  suppressWarnings?: boolean;
  targetOrigin: string;
  to: string;
  type: TSends['type'];
}, {
  requestId: string;
  response: TSends['response'] | null;
  responseTo: string | undefined;
}, {
  type: 'request.failed';
  requestId: string;
} | {
  type: 'request.aborted';
  requestId: string;
} | {
  type: 'request.success';
  requestId: string;
  response: MessageData | null;
  responseTo: string | undefined;
}, import("xstate").MetaObject, {
  states: {
    readonly idle: {};
    readonly sending: {};
    readonly awaiting: {};
    readonly failed: {};
    readonly success: {};
    readonly aborted: {};
  };
}>;
/**
 * @public
 */
type ConnectionActorLogic<TSends extends Message, TReceives extends Message> = ReturnType<typeof createConnectionMachine<TSends, TReceives>>;
/**
 * @public
 */
type ConnectionActor<TSends extends Message, TReceives extends Message> = ActorRefFrom<ReturnType<typeof createConnectionMachine<TSends, TReceives>>>;
/**
 * @public
 */
type Connection<TSends extends Message = Message, TReceives extends Message = Message> = {
  actor: ConnectionActor<TSends, TReceives>;
  connect: () => void;
  disconnect: () => void;
  id: string;
  name: string;
  machine: ReturnType<typeof createConnectionMachine<TSends, TReceives>>;
  on: <TType extends TReceives['type'], TMessage extends Extract<TReceives, {
    type: TType;
  }>>(type: TType, handler: (data: TMessage['data']) => Promise<TMessage['response']> | TMessage['response']) => () => void;
  onStatus: (handler: (status: Status) => void, filter?: Status) => () => void;
  post: <TType extends TSends['type'], TMessage extends Extract<TSends, {
    type: TType;
  }>>(...params: (TMessage['data'] extends undefined ? [TType] : never) | [TType, TMessage['data']]) => void;
  setTarget: (target: MessageEventSource) => void;
  start: () => () => void;
  stop: () => void;
  target: MessageEventSource | undefined;
};
/**
 * @public
 */
interface ConnectionInput {
  connectTo: string;
  domain?: string;
  heartbeat?: boolean;
  name: string;
  id?: string;
  target?: MessageEventSource;
  targetOrigin: string;
}
/**
 * @public
 */
declare const createConnectionMachine: <TSends extends Message // Sends
, TReceives extends Message // Receives
, TSendsWithoutResponse extends WithoutResponse<TSends> = WithoutResponse<TSends>>() => import("xstate").StateMachine<{
  buffer: Array<TSendsWithoutResponse>;
  channelId: string;
  connectTo: string;
  domain: string;
  heartbeat: boolean;
  id: string;
  name: string;
  requests: Array<RequestActorRef<TSends>>;
  target: MessageEventSource | undefined;
  targetOrigin: string;
}, {
  type: 'connect';
} | {
  type: 'disconnect';
} | {
  type: 'message.received';
  message: MessageEvent<ProtocolMessage<TReceives>>;
} | {
  type: 'post';
  data: TSendsWithoutResponse;
} | {
  type: 'response';
  respondTo: string;
  data: Pick<TSends, 'response'>;
} | {
  type: 'request.aborted';
  requestId: string;
} | {
  type: 'request.failed';
  requestId: string;
} | {
  type: 'request.success';
  requestId: string;
  response: TSends['response'] | null;
  responseTo: string | undefined;
} | {
  type: 'request';
  data: RequestData<TSends> | RequestData<TSends>[];
} | {
  type: 'syn';
} | {
  type: 'target.set';
  target: MessageEventSource;
}, {
  [x: string]: import("xstate").ActorRefFromLogic<import("xstate").StateMachine<RequestMachineContext<TSends>, {
    type: 'message';
    data: ProtocolMessage<ResponseMessage>;
  } | {
    type: 'abort';
  }, {
    "listen for response"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage<ResponseMessage>>, {
      requestId: string;
      sources: Set<MessageEventSource>;
      signal?: AbortSignal;
    }, EventObject>> | undefined;
  }, {
    src: "listen";
    logic: import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage<ResponseMessage>>, {
      requestId: string;
      sources: Set<MessageEventSource>;
      signal?: AbortSignal;
    }, EventObject>;
    id: "listen for response";
  }, {
    type: "on abort";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "on fail";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "on success";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "send message";
    params: {
      message: ProtocolMessage;
    };
  }, {
    type: "expectsResponse";
    params: unknown;
  }, "initialTimeout" | "responseTimeout", "aborted" | "awaiting" | "failed" | "idle" | "sending" | "success", string, {
    channelId: string;
    data?: TSends["data"] | undefined;
    domain: string;
    expectResponse?: boolean;
    from: string;
    parentRef: import("xstate").AnyActorRef;
    resolvable?: PromiseWithResolvers<TSends["response"]> | undefined;
    responseTimeout?: number;
    responseTo?: string;
    signal?: AbortSignal;
    sources: Set<MessageEventSource> | MessageEventSource;
    suppressWarnings?: boolean;
    targetOrigin: string;
    to: string;
    type: TSends["type"];
  }, {
    requestId: string;
    response: TSends["response"] | null;
    responseTo: string | undefined;
  }, {
    type: 'request.failed';
    requestId: string;
  } | {
    type: 'request.aborted';
    requestId: string;
  } | {
    type: 'request.success';
    requestId: string;
    response: MessageData | null;
    responseTo: string | undefined;
  }, import("xstate").MetaObject, {
    states: {
      readonly idle: {};
      readonly sending: {};
      readonly awaiting: {};
      readonly failed: {};
      readonly success: {};
      readonly aborted: {};
    };
  }>> | undefined;
  "listen for handshake"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<{
    type: string;
    message: MessageEvent<ProtocolMessage>;
  }, ListenInput, EventObject>> | undefined;
  "listen for messages"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<{
    type: string;
    message: MessageEvent<ProtocolMessage>;
  }, ListenInput, EventObject>> | undefined;
  "send heartbeat"?: import("xstate").ActorRefFromLogic<import("xstate").CallbackActorLogic<EventObject, {
    event: EventObject;
    immediate?: boolean;
    interval: number;
  }, EventObject>> | undefined;
  "send syn"?: import("xstate").ActorRefFromLogic<import("xstate").CallbackActorLogic<EventObject, {
    event: EventObject;
    immediate?: boolean;
    interval: number;
  }, EventObject>> | undefined;
}, {
  src: "listen";
  logic: import("xstate").ObservableActorLogic<{
    type: string;
    message: MessageEvent<ProtocolMessage>;
  }, ListenInput, EventObject>;
  id: "listen for handshake" | "listen for messages";
} | {
  src: "requestMachine";
  logic: import("xstate").StateMachine<RequestMachineContext<TSends>, {
    type: 'message';
    data: ProtocolMessage<ResponseMessage>;
  } | {
    type: 'abort';
  }, {
    "listen for response"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage<ResponseMessage>>, {
      requestId: string;
      sources: Set<MessageEventSource>;
      signal?: AbortSignal;
    }, EventObject>> | undefined;
  }, {
    src: "listen";
    logic: import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage<ResponseMessage>>, {
      requestId: string;
      sources: Set<MessageEventSource>;
      signal?: AbortSignal;
    }, EventObject>;
    id: "listen for response";
  }, {
    type: "on abort";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "on fail";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "on success";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "send message";
    params: {
      message: ProtocolMessage;
    };
  }, {
    type: "expectsResponse";
    params: unknown;
  }, "initialTimeout" | "responseTimeout", "aborted" | "awaiting" | "failed" | "idle" | "sending" | "success", string, {
    channelId: string;
    data?: TSends["data"] | undefined;
    domain: string;
    expectResponse?: boolean;
    from: string;
    parentRef: import("xstate").AnyActorRef;
    resolvable?: PromiseWithResolvers<TSends["response"]> | undefined;
    responseTimeout?: number;
    responseTo?: string;
    signal?: AbortSignal;
    sources: Set<MessageEventSource> | MessageEventSource;
    suppressWarnings?: boolean;
    targetOrigin: string;
    to: string;
    type: TSends["type"];
  }, {
    requestId: string;
    response: TSends["response"] | null;
    responseTo: string | undefined;
  }, {
    type: 'request.failed';
    requestId: string;
  } | {
    type: 'request.aborted';
    requestId: string;
  } | {
    type: 'request.success';
    requestId: string;
    response: MessageData | null;
    responseTo: string | undefined;
  }, import("xstate").MetaObject, {
    states: {
      readonly idle: {};
      readonly sending: {};
      readonly awaiting: {};
      readonly failed: {};
      readonly success: {};
      readonly aborted: {};
    };
  }>;
  id: string | undefined;
} | {
  src: "sendBackAtInterval";
  logic: import("xstate").CallbackActorLogic<EventObject, {
    event: EventObject;
    immediate?: boolean;
    interval: number;
  }, EventObject>;
  id: "send heartbeat" | "send syn";
}, {
  type: "buffer message";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "create request";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "emit received message";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "emit status";
  params: {
    status: Status;
  };
} | {
  type: "post message";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "remove request";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "respond";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "send disconnect";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "send handshake ack";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "send handshake syn";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "send pending messages";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "set target";
  params: import("xstate").NonReducibleUnknown;
}, {
  type: "has target";
  params: unknown;
} | {
  type: "should send heartbeats";
  params: unknown;
}, never, "disconnected" | "handshaking" | "idle" | {
  connected: {
    heartbeat: "checking" | "sending";
  };
}, string, ConnectionInput, import("xstate").NonReducibleUnknown, BufferAddedEmitEvent<TSendsWithoutResponse> | BufferFlushedEmitEvent<TSendsWithoutResponse> | MessageEmitEvent<TReceives> | StatusEmitEvent, import("xstate").MetaObject, {
  id: "connection";
  states: {
    readonly idle: {};
    readonly handshaking: {
      id: "handshaking";
    };
    readonly connected: {
      states: {
        readonly heartbeat: {
          states: {
            readonly checking: {};
            readonly sending: {};
          };
        };
      };
    };
    readonly disconnected: {
      id: "disconnected";
    };
  };
}>;
/**
 * @public
 */
declare const createConnection: <TSends extends Message, TReceives extends Message>(input: ConnectionInput, machine?: ConnectionActorLogic<TSends, TReceives>) => Connection<TSends, TReceives>;
/**
 * @public
 */
declare const createListenLogic: (compatMap?: (event: MessageEvent<ProtocolMessage>) => MessageEvent<ProtocolMessage>) => import("xstate").ObservableActorLogic<{
  type: string;
  message: MessageEvent<ProtocolMessage>;
}, ListenInput, import("xstate").EventObject>;
/**
 * @public
 */
type ChannelInput = Omit<ConnectionInput, 'target' | 'targetOrigin'>;
/**
 * @public
 */
interface ChannelInstance<TSends extends Message, TReceives extends Message> {
  on: <TType extends TReceives['type'], TMessage extends Extract<TReceives, {
    type: TType;
  }>>(type: TType, handler: (data: TMessage['data']) => Promise<TMessage['response']> | TMessage['response']) => () => void;
  onInternalEvent: <TType extends InternalEmitEvent<TSends, TReceives>['type'], TEvent extends Extract<InternalEmitEvent<TSends, TReceives>, {
    type: TType;
  }>>(type: TType, handler: (event: TEvent) => void) => () => void;
  onStatus: (handler: (event: StatusEvent) => void) => void;
  post: <TType extends TSends['type'], TMessage extends Extract<TSends, {
    type: TType;
  }>>(...params: (TMessage['data'] extends undefined ? [TType] : never) | [TType, TMessage['data']]) => void;
  start: () => () => void;
  stop: () => void;
}
/**
 * @public
 */
interface Controller {
  addTarget: (target: MessageEventSource) => () => void;
  createChannel: <TSends extends Message, TReceives extends Message>(input: ChannelInput, machine?: ConnectionActorLogic<TSends, TReceives>) => ChannelInstance<TSends, TReceives>;
  destroy: () => void;
}
/**
 * @public
 */
declare const createController: (input: {
  targetOrigin: string;
}) => Controller;
/**
 * @public
 */
interface NodeInput {
  name: string;
  connectTo: string;
  domain?: string;
}
/**
 * @public
 */
type NodeActorLogic<TSends extends Message, TReceives extends Message> = ReturnType<typeof createNodeMachine<TSends, TReceives>>;
/**
 * @public
 */
type NodeActor<TSends extends Message, TReceives extends Message> = ActorRefFrom<NodeActorLogic<TSends, TReceives>>;
/**
 * @public
 */
type Node<TSends extends Message, TReceives extends Message> = {
  actor: NodeActor<TSends, TReceives>;
  fetch: <TType extends TSends['type'], TMessage extends Extract<TSends, {
    type: TType;
  }>>(...params: (TMessage['data'] extends undefined ? [TType] : never) | [TType, TMessage['data']] | [TType, TMessage['data'], {
    signal?: AbortSignal;
    suppressWarnings?: boolean;
  }]) => TSends extends TMessage ? TSends['type'] extends TType ? Promise<TSends['response']> : never : never;
  machine: NodeActorLogic<TSends, TReceives>;
  on: <TType extends TReceives['type'], TMessage extends Extract<TReceives, {
    type: TType;
  }>>(type: TType, handler: (event: TMessage['data']) => TMessage['response']) => () => void;
  onStatus: (handler: (status: Exclude<Status, 'disconnected'>) => void, filter?: Exclude<Status, 'disconnected'>) => () => void;
  post: <TType extends TSends['type'], TMessage extends Extract<TSends, {
    type: TType;
  }>>(...params: (TMessage['data'] extends undefined ? [TType] : never) | [TType, TMessage['data']]) => void;
  start: () => () => void;
  stop: () => void;
};
/**
 * @public
 */
declare const createNodeMachine: <TSends extends Message // Sends
, TReceives extends Message // Receives
, TSendsWithoutResponse extends WithoutResponse<TSends> = WithoutResponse<TSends>>() => import("xstate").StateMachine<{
  buffer: Array<{
    data: TSendsWithoutResponse;
    resolvable?: PromiseWithResolvers<TSends['response']>;
    options?: {
      signal?: AbortSignal;
      suppressWarnings?: boolean;
    };
  }>;
  channelId: string | null;
  connectTo: string;
  domain: string;
  handshakeBuffer: Array<{
    type: 'message.received';
    message: MessageEvent<ProtocolMessage<TReceives>>;
  }>;
  name: string;
  requests: Array<RequestActorRef<TSends>>;
  target: MessageEventSource | undefined;
  targetOrigin: string | null;
}, {
  type: 'heartbeat.received';
  message: MessageEvent<ProtocolMessage<HeartbeatMessage>>;
} | {
  type: 'message.received';
  message: MessageEvent<ProtocolMessage<TReceives>>;
} | {
  type: 'handshake.syn';
  message: MessageEvent<ProtocolMessage<TReceives>>;
} | {
  type: 'post';
  data: TSendsWithoutResponse;
  resolvable?: PromiseWithResolvers<TSends['response']>;
  options?: {
    responseTimeout?: number;
    signal?: AbortSignal;
    suppressWarnings?: boolean;
  };
} | {
  type: 'request.aborted';
  requestId: string;
} | {
  type: 'request.failed';
  requestId: string;
} | {
  type: 'request.success';
  requestId: string;
  response: TSends['response'] | null;
  responseTo: string | undefined;
} | {
  type: 'request';
  data: RequestData<TSends> | RequestData<TSends>[];
}, {
  [x: string]: import("xstate").ActorRefFromLogic<import("xstate").StateMachine<RequestMachineContext<TSends>, {
    type: 'message';
    data: ProtocolMessage<ResponseMessage>;
  } | {
    type: 'abort';
  }, {
    "listen for response"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage<ResponseMessage>>, {
      requestId: string;
      sources: Set<MessageEventSource>;
      signal?: AbortSignal;
    }, import("xstate").EventObject>> | undefined;
  }, {
    src: "listen";
    logic: import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage<ResponseMessage>>, {
      requestId: string;
      sources: Set<MessageEventSource>;
      signal?: AbortSignal;
    }, import("xstate").EventObject>;
    id: "listen for response";
  }, {
    type: "on abort";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "on fail";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "on success";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "send message";
    params: {
      message: ProtocolMessage;
    };
  }, {
    type: "expectsResponse";
    params: unknown;
  }, "initialTimeout" | "responseTimeout", "aborted" | "awaiting" | "failed" | "idle" | "sending" | "success", string, {
    channelId: string;
    data?: TSends["data"] | undefined;
    domain: string;
    expectResponse?: boolean;
    from: string;
    parentRef: import("xstate").AnyActorRef;
    resolvable?: PromiseWithResolvers<TSends["response"]> | undefined;
    responseTimeout?: number;
    responseTo?: string;
    signal?: AbortSignal;
    sources: Set<MessageEventSource> | MessageEventSource;
    suppressWarnings?: boolean;
    targetOrigin: string;
    to: string;
    type: TSends["type"];
  }, {
    requestId: string;
    response: TSends["response"] | null;
    responseTo: string | undefined;
  }, {
    type: 'request.failed';
    requestId: string;
  } | {
    type: 'request.aborted';
    requestId: string;
  } | {
    type: 'request.success';
    requestId: string;
    response: MessageData | null;
    responseTo: string | undefined;
  }, import("xstate").MetaObject, {
    states: {
      readonly idle: {};
      readonly sending: {};
      readonly awaiting: {};
      readonly failed: {};
      readonly success: {};
      readonly aborted: {};
    };
  }>> | undefined;
  "listen for disconnect"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<{
    type: string;
    message: MessageEvent<ProtocolMessage>;
  }, ListenInput, import("xstate").EventObject>> | undefined;
  "listen for handshake ack"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<{
    type: string;
    message: MessageEvent<ProtocolMessage>;
  }, ListenInput, import("xstate").EventObject>> | undefined;
  "listen for handshake syn"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<{
    type: string;
    message: MessageEvent<ProtocolMessage>;
  }, ListenInput, import("xstate").EventObject>> | undefined;
  "listen for heartbeat"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<{
    type: string;
    message: MessageEvent<ProtocolMessage>;
  }, ListenInput, import("xstate").EventObject>> | undefined;
  "listen for messages"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<{
    type: string;
    message: MessageEvent<ProtocolMessage>;
  }, ListenInput, import("xstate").EventObject>> | undefined;
}, {
  src: "listen";
  logic: import("xstate").ObservableActorLogic<{
    type: string;
    message: MessageEvent<ProtocolMessage>;
  }, ListenInput, import("xstate").EventObject>;
  id: "listen for disconnect" | "listen for handshake ack" | "listen for handshake syn" | "listen for heartbeat" | "listen for messages";
} | {
  src: "requestMachine";
  logic: import("xstate").StateMachine<RequestMachineContext<TSends>, {
    type: 'message';
    data: ProtocolMessage<ResponseMessage>;
  } | {
    type: 'abort';
  }, {
    "listen for response"?: import("xstate").ActorRefFromLogic<import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage<ResponseMessage>>, {
      requestId: string;
      sources: Set<MessageEventSource>;
      signal?: AbortSignal;
    }, import("xstate").EventObject>> | undefined;
  }, {
    src: "listen";
    logic: import("xstate").ObservableActorLogic<MessageEvent<ProtocolMessage<ResponseMessage>>, {
      requestId: string;
      sources: Set<MessageEventSource>;
      signal?: AbortSignal;
    }, import("xstate").EventObject>;
    id: "listen for response";
  }, {
    type: "on abort";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "on fail";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "on success";
    params: import("xstate").NonReducibleUnknown;
  } | {
    type: "send message";
    params: {
      message: ProtocolMessage;
    };
  }, {
    type: "expectsResponse";
    params: unknown;
  }, "initialTimeout" | "responseTimeout", "aborted" | "awaiting" | "failed" | "idle" | "sending" | "success", string, {
    channelId: string;
    data?: TSends["data"] | undefined;
    domain: string;
    expectResponse?: boolean;
    from: string;
    parentRef: import("xstate").AnyActorRef;
    resolvable?: PromiseWithResolvers<TSends["response"]> | undefined;
    responseTimeout?: number;
    responseTo?: string;
    signal?: AbortSignal;
    sources: Set<MessageEventSource> | MessageEventSource;
    suppressWarnings?: boolean;
    targetOrigin: string;
    to: string;
    type: TSends["type"];
  }, {
    requestId: string;
    response: TSends["response"] | null;
    responseTo: string | undefined;
  }, {
    type: 'request.failed';
    requestId: string;
  } | {
    type: 'request.aborted';
    requestId: string;
  } | {
    type: 'request.success';
    requestId: string;
    response: MessageData | null;
    responseTo: string | undefined;
  }, import("xstate").MetaObject, {
    states: {
      readonly idle: {};
      readonly sending: {};
      readonly awaiting: {};
      readonly failed: {};
      readonly success: {};
      readonly aborted: {};
    };
  }>;
  id: string | undefined;
}, {
  type: "buffer handshake";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "buffer message";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "create request";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "emit heartbeat";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "emit received message";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "emit status";
  params: {
    status: Exclude<Status, 'disconnected'>;
  };
} | {
  type: "post message";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "process pending handshakes";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "remove request";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "send handshake syn ack";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "send pending messages";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "send response";
  params: import("xstate").NonReducibleUnknown;
} | {
  type: "set connection config";
  params: import("xstate").NonReducibleUnknown;
}, {
  type: "hasSource";
  params: unknown;
}, never, "connected" | "handshaking" | "idle", string, NodeInput, import("xstate").NonReducibleUnknown, BufferAddedEmitEvent<TSendsWithoutResponse> | BufferFlushedEmitEvent<TSendsWithoutResponse> | HeartbeatEmitEvent | MessageEmitEvent<TReceives> | (StatusEmitEvent & {
  status: Exclude<Status, 'disconnected'>;
}), import("xstate").MetaObject, {
  id: "node";
  states: {
    readonly idle: {};
    readonly handshaking: {};
    readonly connected: {};
  };
}>;
/**
 * @public
 */
declare const createNode: <TSends extends Message, TReceives extends Message>(input: NodeInput, machine?: NodeActorLogic<TSends, TReceives>) => Node<TSends, TReceives>;
export { type BufferAddedEmitEvent, type BufferFlushedEmitEvent, type ChannelInput, type ChannelInstance, type Connection, type ConnectionActor, type ConnectionActorLogic, type ConnectionInput, type Controller, DOMAIN, type DisconnectMessage, FETCH_TIMEOUT_DEFAULT, HANDSHAKE_INTERVAL, HANDSHAKE_MSG_TYPES, HEARTBEAT_INTERVAL, type HandshakeMessageType, type HeartbeatEmitEvent, type HeartbeatMessage, INTERNAL_MSG_TYPES, type InternalEmitEvent, type InternalMessageType, type ListenInput, MSG_DISCONNECT, MSG_HANDSHAKE_ACK, MSG_HANDSHAKE_SYN, MSG_HANDSHAKE_SYN_ACK, MSG_HEARTBEAT, MSG_RESPONSE, type Message, type MessageData, type MessageEmitEvent, type MessageType, type Node, type NodeActor, type NodeActorLogic, type NodeInput, type ProtocolMessage, RESPONSE_TIMEOUT_DEFAULT, type RequestActorRef, type RequestData, type RequestMachineContext, type ResponseMessage, type Status, type StatusEmitEvent, type StatusEvent, type WithoutResponse, createConnection, createConnectionMachine, createController, createListenLogic, createNode, createNodeMachine, createRequestMachine };
//# sourceMappingURL=index.d.ts.map