export type ProductKind = 'physical' | 'digital' | 'voucher'

export type PriceMode = 'inclusive' | 'exclusive'

export type Money = { amount: bigint; currency: string }

export type MediaRef = { key: string; alt?: string }

export type VariantPrice = { currency: string; amount: bigint; priceMode: PriceMode }

export type ProductStatus = 'draft' | 'active' | 'archived'

export interface Product {
  id: string
  kind: ProductKind
  vendorId: string | null
  slug: string
  title: string
  description?: string
  status: ProductStatus
  media: MediaRef[]
  tags: string[]
  availableFrom?: Date | null
  availableUntil?: Date | null
  createdAt: Date
  updatedAt: Date
  /** Hydrated read shape — variants with multi-currency prices loaded from variant_price. */
  variants: Variant[]
}

export interface Variant {
  id: string
  productId: string
  sku: string
  attributes: Record<string, unknown>
  prices: VariantPrice[]
}

export interface ProductInput {
  id?: string
  kind: ProductKind
  vendorId?: string | null
  slug: string
  title: string
  description?: string
  status?: ProductStatus
  media?: MediaRef[]
  tags?: string[]
  availableFrom?: Date | null
  availableUntil?: Date | null
}

export interface CatalogFilter {
  audience: 'public' | 'admin'
  category?: string
  collection?: string
  tag?: string
  kind?: ProductKind
  status?: ProductStatus
  vendorId?: string
  /** Candidate-set faceting hook — undefined = unused, [] = match nothing. */
  entityIds?: string[]
  page?: number
  now?: Date
}

export type Page<T> = {
  items: T[]
  total: number
  page: number
  pageSize: number
  /** Set true ONLY when entityIds candidate set was sliced by catalog's MAX_ENTITY_IDS cap. */
  entityIdsCapped?: boolean
}
