/**
 * Public events for one character-scoped Chat actor.
 * Authentication synchronization dispatches the lifecycle events; history,
 * quota, send, and unlock side effects remain owned by the machine.
 */
import type { PendingChatUnlockKind } from "@/lib/navigation/chat_unlock_session";
import type { ChatLockType } from "@/data/schemas/chat";
import type { PendingChatPromotion } from "@/data/storage/navigation";

export type ChatEvent =
  // Authentication lifecycle dispatched by ChatAuthSync.
  | { type: "ChatGuestLogin" }
  | { type: "ChatUserLogin"; token: string }
  | { type: "ChatLogout" }
  | {
      type: "ChatLocalHistoryLoaded";
      output: import("./chat-history-sync").LocalHistorySnapshotOutput;
    }
  | {
      type: "ChatNetworkHistoryLoaded";
      output: import("./chat-history-sync").NetworkHistorySyncOutput;
    }
  | { type: "ChatHistoryLoadFailed"; error: unknown }
  | { type: "ChatLoadMoreHistoryRequested" }
  | {
      type: "ChatOlderHistoryLoaded";
      output: import("./machine/actors/history").LoadMoreHistoryOutput;
    }
  | { type: "ChatOlderHistoryLoadFailed"; error: unknown }
  | { type: "ChatHistoryRefreshRequested" }
  | {
      type: "ChatCommercialMessageReceived";
      message: {
        messageId: string;
        message: string;
        characterId: string;
        createdAt: string;
      };
    }
  // Chat domain events.
  | { type: "ChatSendMessage"; content: string }
  | { type: "ChatSendImage"; imageBase64: string }
  | {
      type: "ChatPromotionInjected";
      promotion: PendingChatPromotion;
      messageId?: string;
    }
  | { type: "ChatPromotionCleared" }
  | {
      type: "ChatUnlockMessageRequested";
      displayMessageId: string;
      remoteMessageId?: string;
      kind: PendingChatUnlockKind;
      lockType?: ChatLockType;
      clientLockId?: string;
    }
  | { type: "ChatUnlockPaywallNavigationConsumed" }
  | { type: "ChatPaymentSucceeded" }
  | { type: "ChatUnlockHistoryConfirmed" }
  | { type: "ChatUnlockHistoryDismissed" }
  | { type: "ChatQueuedSendStarted" }
  | {
      type: "ChatQueuedHttpDone";
      output: import("./helper/send-state").HttpSendOutput;
    }
  | {
      type: "ChatQueuedSendError";
      content: string;
      errorMessage: string;
      characterErrorCode?: import("@/data/services/api").CharacterErrorCode;
    };
