import {
  D as ChannelInboundMessage,
  F as ChannelMessageSurface,
  U as UserIdentity,
  V as ChannelIdentity,
  a as ChannelApprovalRequestOptions,
  d as ChannelRoute,
  h as DeliveryResult,
  j as ChannelIngressEvent,
  l as ChannelDeliveryOptions,
  n as Channel,
  p as ChannelStreamOptions,
  s as ChannelChunkSource,
  u as ChannelMessage,
  w as ChannelEmailInput,
  y as ChannelApprovalResponse
} from "./channel-Bnm4S7T2.js";

//#region src/channels/host/index.d.ts
type ChannelMessageEvent = {
  channelKey: string;
  route: string /** Stable identity derived only from the configured Channel and eventId. */;
  dispatchId: string;
  message: ChannelInboundMessage;
};
type ChannelApprovalResponseEvent = {
  channelKey: string;
  route: string /** Stable identity derived only from the configured Channel and eventId. */;
  dispatchId: string;
  response: ChannelApprovalResponse;
};
type ChannelRouteEvent = {
  channelKey: string;
  event: ChannelIngressEvent;
  route:
    | string
    | null /** Stable identity derived only from the configured Channel and eventId. */;
  dispatchId: string;
};
type ChannelHostOptions = {
  channels: Record<
    string,
    Channel
  > /** Used when a Channel does not provide a route. Default: event thread id. */;
  defaultRoute?: ChannelRoute /** Resolve an existing, explicitly linked application user. */;
  findUser?(
    identity: ChannelIdentity
  ): Promise<UserIdentity | null> /** Observes every valid route outcome before application dispatch. */;
  onRoute?(event: ChannelRouteEvent): void | Promise<void>;
  onMessage?(event: ChannelMessageEvent): void | Promise<void>;
  onApprovalResponse?(
    event: ChannelApprovalResponseEvent
  ): void | Promise<void>;
};
/**
 * Authenticates and normalizes ingress through configured Channel adapters,
 * resolves outbound surfaces, and awaits the application's durable handoff.
 */
declare class ChannelHost {
  #private;
  constructor(options: ChannelHostOptions);
  handleRequest(request: Request): Promise<Response | undefined>;
  handleEmail(email: ChannelEmailInput): Promise<boolean>;
  /** Deliver through the configured Channel or composite named by the surface. */
  deliver(
    surface: ChannelMessageSurface,
    message: ChannelMessage,
    options?: ChannelDeliveryOptions
  ): Promise<DeliveryResult>;
  /**
   * Deliver a progressively generated answer to the Channel or composite
   * named by the surface.
   *
   * A Channel that can stream consumes the stream itself. A Channel that
   * cannot never learns it was a stream, because the Host collects the answer
   * and calls `deliver` once.
   */
  stream(
    surface: ChannelMessageSurface,
    chunks: ChannelChunkSource,
    options?: ChannelStreamOptions
  ): Promise<DeliveryResult>;
  /** Request approval through the Channel or composite named by the surface. */
  requestApproval(
    surface: ChannelMessageSurface,
    options: ChannelApprovalRequestOptions
  ): Promise<DeliveryResult>;
  /** Return the identity's configured Channel destination, when supported. */
  contactSurface(identity: ChannelIdentity): ChannelMessageSurface | null;
  /** Resolve whether a surface can currently be selected without delivery. */
  isAvailable(surface: ChannelMessageSurface): Promise<boolean>;
}
//#endregion
export {
  ChannelRouteEvent as a,
  ChannelMessageEvent as i,
  ChannelHost as n,
  ChannelHostOptions as r,
  ChannelApprovalResponseEvent as t
};
//# sourceMappingURL=index-BB0kqhIz.d.ts.map
