export type AdminDrawListItem = {
  id: number;
  draw_no: string;
  business_date: string;
  sequence_no: number;
  status: string;
  start_time: string | null;
  close_time: string | null;
  draw_time: string | null;
  cooling_end_time: string | null;
  result_source?: string | null;
  current_result_version?: number;
  settle_version?: number;
  is_reopened?: boolean;
  total_bet_minor?: number;
  total_payout_minor?: number;
  profit_loss_minor?: number;
  updated_at: string | null;
};

export type AdminDrawListMeta = {
  current_page: number;
  per_page: number;
  total: number;
  last_page: number;
};

export type AdminDrawScheduleMeta = {
  timezone: string;
  interval_minutes: number;
  betting_window_seconds: number;
  close_before_draw_seconds: number;
};

export type AdminDrawListData = {
  items: AdminDrawListItem[];
  meta: AdminDrawListMeta;
  schedule?: AdminDrawScheduleMeta;
};

export type AdminDrawCreatePayload = {
  draw_time: string;
  start_time?: string;
  close_time?: string;
  draw_no?: string;
  business_date?: string;
  sequence_no?: number;
};

export type AdminDrawCreateResponse = {
  id: number;
  draw_no: string;
  business_date: string;
  sequence_no: number;
  status: string;
  start_time: string | null;
  close_time: string | null;
  draw_time: string | null;
};

export type AdminDrawShowData = {
  id: number;
  draw_no: string;
  business_date: string;
  sequence_no: number;
  status: string;
  hall_preview_status: string;
  total_bet_minor?: number;
  total_payout_minor?: number;
  profit_loss_minor?: number;
  start_time: string | null;
  close_time: string | null;
  draw_time: string | null;
  cooling_end_time: string | null;
  result_source?: string | null;
  current_result_version?: number;
  settle_version?: number;
  is_reopened?: boolean;
  created_at?: string | null;
  updated_at?: string | null;
  result_batch_counts: {
    total?: number;
    pending_review?: number;
    published: number;
  };
  capabilities?: {
    can_manage_draw_results: boolean;
    can_view_draw_finance: boolean;
  };
};

export type AdminDrawBatchItemRow = {
  prize_type: string;
  prize_index: number;
  number_4d: string;
  suffix_3d: string | null;
  suffix_2d: string | null;
  head_digit: number | null;
  tail_digit: number | null;
};

export type AdminDrawBatchRow = {
  id: number;
  result_version: number;
  source_type?: string;
  rng_seed_hash?: string | null;
  status: string;
  created_by?: number | null;
  confirmed_by?: number | null;
  confirmed_at: string | null;
  created_at?: string | null;
  updated_at?: string | null;
  items: AdminDrawBatchItemRow[];
};

export type AdminDrawBatchesData = {
  draw_id: number;
  draw_no: string;
  draw_status: string;
  batches: AdminDrawBatchRow[];
};

export type AdminDrawPublishResponse = {
  draw_no: string;
  status: string;
  result_version: number;
};

export type AdminDrawActionResponse = {
  draw_no: string;
  status: string;
  close_time?: string | null;
  is_reopened?: boolean;
  current_result_version?: number;
  cooling_end_time?: string | null;
};

export type AdminDrawPlanGenerateResponse = {
  created: number;
  buffer_target: number;
  upcoming: number;
};

export type AdminDrawManualBatchPayload = {
  items: Array<{
    prize_type: string;
    prize_index: number;
    number_4d: string;
  }>;
};

export type AdminDrawBatchCreateResponse = {
  draw_no: string;
  status: string;
  batch: {
    id: number;
    result_version: number;
    source_type: string;
    status: string;
    items_count: number;
  };
};
