import type { CouponModel } from '../../../orm/src/models/Coupon';
import type { GiftCardJsonResponse } from '../../../orm/src/models/GiftCard';
import type { ManufacturerJsonResponse } from '../../../orm/src/models/Manufacturer';
import type { OrderItemModel } from '../../../orm/src/models/OrderItem';
import type { OrderJsonResponse } from '../../../orm/src/models/Order';
import type { ReviewJsonResponse } from '../../../orm/src/models/Review';

export type {
export declare interface CustomerResponse {
  data: CustomerJsonResponse[]
  paging: {
    total_records: number
    page: number
    total_pages: number
  }
  next_cursor: number | null
}
export declare interface CreateCustomerInput {
  name: string
  email: string
  phone: string
  orders?: number
  total_spent?: number 
  last_order?: string 
  status?: string
  avatar?: string
  user_id?: number
}
export declare interface UpdateCustomerInput {
  name?: string
  email?: string
  phone?: string
  orders?: number
  total_spent?: number 
  last_order?: string 
  status?: string
  avatar?: string
  user_id?: number
}
export declare interface OrderItem {
  product_id: string
  quantity: number
  price: number
  special_instructions?: string
}
export declare interface StatusCount {
  status: string
  count: number | string 
}
export declare interface OrderTypeCount {
  order_type: string
  count: number | string 
}
export declare interface OrderStats {
  total: number
  by_status: StatusCount[]
  by_type: OrderTypeCount[]
  recent: OrderJsonResponse[]
  revenue: number
}
export declare interface OrderItemForCalculation {
  price: number
  quantity: number
}
export declare interface OrderTotals {
  subtotal: number
  tax_amount: number
  total_amount: number
}
export declare interface DiscountTypeCount {
  discount_type: string | undefined
  count: string | number | bigint
}
export declare interface CouponStats {
  total: number

  active: number

  by_type: DiscountTypeCount[]

  most_used: {
    id: number | undefined
    code: string | undefined
    discount_type: string | undefined
    discount_value: number | undefined
    usage_count: number | undefined
  }[]

  upcoming: {
    id: number | undefined
    code: string | undefined
    discount_type: string | undefined
    discount_value: number | undefined
    start_date: Date | string
    end_date: Date | string
  }[]
}
export declare interface OrderWithTotals {
  order_items: OrderItemModel[] | []
  id: number
  customer_id: number
  customer: CustomerModel | undefined
  coupon_id: number
  coupon: CouponModel | undefined
  status: string
  total_amount: number
  tax_amount: number | undefined
  discount_amount: number | undefined
  delivery_fee: number | undefined
  tip_amount: number | undefined
  order_type: string
  delivery_address: string | undefined
  special_instructions: string | undefined
  estimated_delivery_time: string | undefined
  applied_coupon_id: string | undefined
  uuid: string | undefined
  created_at: Date | undefined
  updated_at: Date | undefined
  customer_name: string | null
  customer_email: string | null
  totalItems: number
  totalPrice: number
}
export declare interface FetchGiftCardsOptions {
  page?: number
  limit?: number
  search?: string
  status?: string
  is_active?: boolean
  is_digital?: boolean
  is_reloadable?: boolean
  sortBy?: string
  sortOrder?: 'asc' | 'desc'
  purchaser_id?: string
  from_date?: string
  to_date?: string
  min_balance?: number
  max_balance?: number
}
declare interface BaseResponse {
  paging: {
    total_records: number
    page: number
    total_pages: number
  }
  next_cursor: number | null
}
export declare interface GiftCardResponse extends BaseResponse {
  data: GiftCardJsonResponse[]
}
export declare interface GiftCardStats {
  total: number
  active: number
  by_status: Array<{ status: string, count: number }>
  by_balance: {
    low: number 
    medium: number 
    high: number 
  }
  expiring_soon: GiftCardJsonResponse[]
  recently_used: GiftCardJsonResponse[]
}
export declare interface FetchReviewsOptions {
  page?: number
  limit?: number
}
export declare interface ReviewResponse extends BaseResponse {
  data: ReviewJsonResponse[]
}
export declare interface ProductManufacturerResponse extends BaseResponse {
  data: ManufacturerJsonResponse[]
}
export declare interface ReviewStats {
  total: number
  average_rating: number
  rating_distribution: {
    one_star: number
    two_star: number
    three_star: number
    four_star: number
    five_star: number
  }
  recent_reviews: ReviewJsonResponse[]
}
export declare interface CategoryStats {
  total: number

  active: number

  root_categories: number

  child_categories: number

  with_images: number

  recently_added: Array<any>

  top_parent_categories: Array<{
    id: string
    name: string
    child_count: number
  }>
}
export declare interface FetchProductManufacturersOptions {
  page?: number

  limit?: number

  sortBy?: 'manufacturer' | 'country' | 'created_at' | 'updated_at'

  sortDirection?: 'asc' | 'desc'

  country?: string

  featured?: boolean

  search?: string
}
export declare interface FetchCouponsOptions {
  page?: number
  limit?: number
  search?: string
  is_active?: boolean
  discount_type?: string
  sortBy?: string
  sortOrder?: 'asc' | 'desc'
  product_id?: string
  category_id?: string
  from_date?: string
  to_date?: string
}
export declare interface CouponCountStats {
  total: number
  active: number
  inactive: number
}
export declare interface CouponTimeStats {
  week: CouponCountStats
  month: CouponCountStats
  year: CouponCountStats
  all_time: CouponCountStats
}
export declare interface CouponRedemptionStats {
  total: number
  week: number
  month: number
  year: number
  by_type: Record<string, number>
}
export declare interface FetchOrdersOptions {
  page?: number
  limit?: number
  search?: string
  status?: string
  order_type?: string
  customer_id?: number
  sortBy?: string
  sortOrder?: 'asc' | 'desc'
  from_date?: string
  to_date?: string
}