import type { PackageSection } from '../../organisms/PackageDetail';

// ─── Tier ────────────────────────────────────────────────────────────────────

/**
 * Provider tier — drives header copy, CTA label, disclaimer text, and
 * whether the PackageDetail panel shows an itemised breakdown.
 *
 * - `verified`: Paid-listing provider. Full data, "Make Arrangement" CTA.
 * - `tier3`: Unverified provider with itemised breakdown scraped from public info.
 * - `tier2`: Unverified provider with total price only (no itemised breakdown).
 */
export type ProviderTier = 'verified' | 'tier3' | 'tier2';

// ─── Provider ────────────────────────────────────────────────────────────────

export interface PackagesStepProvider {
  /** Provider name */
  name: string;
  /** Location */
  location: string;
  /** Hero image — typically only supplied for verified providers */
  imageUrl?: string;
  /** Rating */
  rating?: number;
  /** Review count */
  reviewCount?: number;
}

// ─── Package data ────────────────────────────────────────────────────────────

/**
 * Package data for the selection list.
 *
 * For `tier2` providers, callers should pass `sections: []` (and optionally
 * omit `total`); the detail panel switches to "Itemised Pricing Unavailable"
 * automatically based on the `providerTier` prop.
 */
export interface PackageData {
  /** Unique package ID */
  id: string;
  /** Package display name */
  name: string;
  /** Package price in dollars */
  price: number;
  /** Short description shown on the option card */
  description?: string;
  /** Line-item sections for the detail panel (empty for tier2) */
  sections: PackageSection[];
  /** Total price shown between main sections and extras */
  total?: number;
  /** Extra-cost items shown after the total */
  extras?: PackageSection;
  /** Terms and conditions */
  terms?: string;
}

/** A package offered by a nearby verified provider (promoted on unverified pages). */
export interface NearbyVerifiedPackage {
  /** Unique ID */
  id: string;
  /** Package name */
  packageName: string;
  /** Package price in dollars */
  price: number;
  /** Provider name */
  providerName: string;
  /** Provider location */
  location: string;
  /** Provider rating */
  rating?: number;
  /** Number of reviews */
  reviewCount?: number;
}

// ─── Secondary list ──────────────────────────────────────────────────────────

/**
 * Discriminated union for the second list below the primary packages.
 *
 * - `same-provider-more`: Other packages from the same (verified) provider.
 *   Rendered as a ServiceOption list. If more than 3, the list shows the
 *   first 3 + a "See all N packages from [Provider]" link that navigates
 *   to the same PackagesStep with preference filters off.
 * - `nearby-verified`: Similar packages from nearby verified providers,
 *   promoted on unverified-tier pages. Rendered as NearbyPackageCard list.
 *   Clicking a card is a route change to that provider's PackagesStep.
 */
export type SecondaryList =
  | {
      kind: 'same-provider-more';
      packages: PackageData[];
    }
  | {
      kind: 'nearby-verified';
      packages: NearbyVerifiedPackage[];
    };
