//
//  DiscoverModels.swift

//
//  Created by Leon on 2025/9/10.
//

// MARK: - Discover Home info

struct DiscoverHomeInfo:Codable{
    var aiChatRankTop3List:[AIDiscoverTop]?
    var aiHeartbeatRankTop3List:[AIDiscoverTop]?
    var aiGiftRankTop3List:[AIDiscoverTop]?
    var advertiseList: [AdvertiseOutput]?
}

/// 广告输出对象
struct AdvertiseOutput: Codable {
    /// 广告名称
    var name: String?
    /// 广告配图
    var icon: String?
    /// 跳转连接
    var jumpLink: String?
    /// 展示开始时间
    var showStartTime: String?
    /// 展示结束时间
    var showEndTime: String?
    /// 扩展字段
    var ext: String?
    /// 排序
    var sort: Int?
    /// 使用端点（WEB/ANDROID/IOS）
    var endpoint: String?
    /// 是否弹窗 (1.是,0.否)
    var isGlobal: Int?
}

/// AI 榜单 Top3
struct AIDiscoverTop: Codable {
    /// 排名编号
    var rankNo: Int?
    /// AI 的 id
    var aiId: Int?
    /// 昵称
    var nickname: String?
    /// 性别 (0=男,1=女,2=自定义)
    var sex: Sex?
    /// 头像
    var headImg: String?
    /// 出生日期
    var birthday: Int?
    /// 角色名称
    var roleName: String?
    /// 性格名称
    var characterName: String?
    /// 标签名称
    var tagName: String?
    /// 简介
    var introduction: String?
    /// 主页头图
    var homeImageUrl: String?
    
    var likedNum: Int?

    // MARK: Chat

    /// 聊天次数
    var chatNum: Int?

    // MARK: HeartBeat

    // 心动值分值
    var heartbeatValTotal: CGFloat?

    // MARK: Gift

    var giftCoinNum: Int?
    
    func formateRankDisplayString()->String{
        let rank = rankNo ?? 1
        if rank == 1{
            return "1st"
        }else if rank == 2{
            return "2nd"
        }else {
            return "3rd"
        }
    }
    
    func formateChatDisplay() -> String{
        return String.displayDouble(Double(chatNum ?? 0))
    }
    
    func formateHeartbeatDisplay() ->String {
        return "\(heartbeatValTotal ?? 0.0)℃"
    }
    
    func formateGiftDisplay() ->String{
        return String.displayDouble(Double((giftCoinNum ?? 0))*0.01)
    }
    
}

// MARK: - Daily check

struct Day7CheckList: Codable {
    /// 最大连续签到天数
    var continuousDays: Int?
    
    var list: [Day7CheckListItem]?
    
}

struct Day7CheckListItem:Codable{
    /// PST 天（yyyy-MM-dd）
    var dayStr: String?
    /// 是否已签到
    var signIn: Bool?
    /// 得到coin的数量
    var coinNum: Int?
}

// MARK: - Meet Home

class MeetCard: Codable{
    /// AI 的 id
    var aiId: Int?
    /// 昵称
    var nickname: String?
    /// 性别 (0=男, 1=女, 2=自定义)
    var sex: Sex?
    /// 头像
    var headImg: String?
    /// 年龄
    var age: Int?
    /// 点赞数
    var likedCount: Int?
    /// 角色
    var role: String?
    /// 性格
    var character: String?
    /// 标签
    var tag: String?
    /// 简介
    var introduction: String?
    /// 形象图
    var imageUrl: String?
    
    var albumList:[AlbumPhotoItem]?
    
    var heartbeatVal: CGFloat?
    
    // MARK: Custom property
    var secretAdmirer : Bool?
}

struct MeetMatchInfo: Codable{
    var sex: Sex?
    var introduction: String?
    var characterName: String?
    var likedCount: Int?
    var aiId: Int?
    var userId: Int?
    var birthday: Int?  // 原始毫秒时间戳
    var roleName: String?
    var tagName: String?
    var homeImageUrl: String?
    var liked: Bool?
    var headImg: String?
    var nickname: String?
}

struct MeetCardReportResponse: Codable{
    /// 是否能够调用绑定
    var bd: Bool?
    /// 是否能够调用爱慕者推荐
    var rc: Bool?
}

struct MeetReportAdmirerReturnAlbum: Codable{
    var aiId: Int?
    var albumId: Int?
    var width: String?
    var height: String?
    var img1: String?
    var img2: String?
    var img3: String?

}

// MARK: - Request

enum AIRoleListRequestAge: String, Codable{
    /// 18-24
    case AGE_1
    /// 25-34
    case AGE_2
    /// 35-44
    case AGE_3
    /// 45-54
    case AGE_4
    /// >54
    case AGE_5
    
    var localized: String?{
        switch self {
        case .AGE_1:
            return "18-24"
        case .AGE_2:
            return "25-34"
        case .AGE_3:
            return "35-44"
        case .AGE_4:
            return "45-54"
        case .AGE_5:
            return ">54"
        }
    }
}

struct AIRoleListRequest: Codable{
    var pn = 1
    var ps = 20
    /// 需要排除的aiId列表
    var exList: [Int]?
//    var sex: [Sex]?  // 修改为支持多选
    var sex: Sex?  // 修改为支持多选
    var age : AIRoleListRequestAge?
    var random: Bool?
    var roleCodeList: [String]?
    /// 情感性格Code
    var characterCodeList: [String]?
    /// 标签code列表
    var tagCodeList: [String]?
}
