export type AdminPlayerWalletRow = {
  wallet_type: string;
  currency_code: string;
  balance: number;
  frozen_balance: number;
  available_balance: number;
  status: number;
};

export type PlayerRebateProfileRow = {
  game_type: string;
  rebate_rate: number;
  extra_rebate_rate: number;
  inherit_from_agent: boolean;
};

export type AdminPlayerRow = {
  id: number;
  agent_node_id?: number | null;
  agent_code?: string | null;
  agent_name?: string | null;
  site_code: string;
  site_player_id: string;
  auth_source?: string;
  funding_mode?: string;
  uses_credit?: boolean;
  rebate_inherited?: boolean;
  username: string | null;
  nickname: string | null;
  default_currency: string;
  status: number;
  last_login_at: string | null;
  created_at: string;
  wallets: AdminPlayerWalletRow[];
  credit_limit?: number | null;
  used_credit?: number | null;
  available_credit?: number | null;
  rebate_rate?: number | null;
  risk_tags?: string[];
  rebate_profiles?: PlayerRebateProfileRow[];
};

export type AdminPlayerListData = {
  items: AdminPlayerRow[];
  meta: {
    current_page: number;
    per_page: number;
    total: number;
    last_page: number;
  };
};

export type AdminPlayerCreatePayload = {
  site_code: string;
  site_player_id?: string;
  username?: string | null;
  password?: string;
  nickname?: string | null;
  default_currency?: string;
  status?: number;
  /** 超管可选；未传时后端使用该主站根代理 */
  agent_node_id?: number;
  credit_limit?: number;
  rebate_rate?: number;
  extra_rebate_rate?: number;
};

export type AdminPlayerUpdatePayload = {
  username?: string;
  nickname?: string | null;
  default_currency?: string;
  status?: number;
  credit_limit?: number;
  rebate_rate?: number;
  extra_rebate_rate?: number;
  risk_tags?: string[];
  rebate_profiles?: Array<{
    game_type: string;
    rebate_rate?: number;
    extra_rebate_rate?: number;
    inherit_from_agent?: boolean;
  }>;
};

export type AdminPlayerDeleteResult = {
  deleted: boolean;
};
