/**
 * VendorDeal domain events — discriminated union.
 *
 * Covers the deals.dealState transitions driven by workflows/vendor-deal.ts.
 *
 *   DRAFT      + create_requested(veteran)         → ACTIVE
 *   DRAFT      + create_requested(non-veteran)     → UNDER_REVIEW
 *   ACTIVE     + pause_requested                   → PAUSED
 *   PAUSED     + resume_requested                  → ACTIVE
 *   ACTIVE|PAUSED + archive_requested              → ARCHIVED
 *   REJECTED   + submit_requested                  → UNDER_REVIEW
 *
 * Pure module: no imports from @/server/db, do-client, outbox-producer, payments, fetch.
 */

import type { DealState } from '@/lib/enums/deal-state';
import type { VendorTier } from '@/lib/enums/vendor-tier';
export type { DealState, VendorTier };

export type VendorDealEvent =
  /**
   * Fired AFTER input validation, dedup check, discount-min check, and the
   * DRAFT row insert have all succeeded. The decider only chooses the
   * post-create dealState + which side effects to emit (alarm arm, LLM job).
   */
  | {
      kind: 'create_requested';
      dealId: string;
      vendorId: string;
      vendorTier: VendorTier;
      contentHash: string;
      windowEnd: Date | null;
      llmInputs: {
        title: string;
        description: string;
        categoryId: string | null;
        dealType: string;
        originalPrice: string;
        discountedPrice: string;
        discountPercent: number;
        primaryImageKey: string | null;
      };
      at: Date;
    }
  | {
      kind: 'pause_requested';
      dealId: string;
      at: Date;
    }
  | {
      kind: 'resume_requested';
      dealId: string;
      at: Date;
    }
  | {
      kind: 'archive_requested';
      dealId: string;
      at: Date;
    }
  | {
      kind: 'submit_requested';
      dealId: string;
      at: Date;
    };
