//
//  MPPositive_JsonSearchTypeResults.swift
//  MusicPlayer
//
//  Created by Mr.Zhou on 2024/5/14.
//

import UIKit

///搜索分类结果结构（该分类详情）
struct JsonSearchTypeResults: Codable {
    let contents:Contents?
    enum CodingKeys: String, CodingKey {
        case contents = "contents"
    }
    init(from decoder: Decoder) throws {
        let values = try decoder.container(keyedBy: CodingKeys.self)
        contents = try values.decodeIfPresent(Contents.self, forKey: .contents)
    }
    struct Contents: Codable {
        let tabbedSearchResultsRenderer:TabbedSearchResultsRenderer?
        enum CodingKeys: String, CodingKey {
            case tabbedSearchResultsRenderer = "tabbedSearchResultsRenderer"
        }
        init(from decoder: Decoder) throws {
            let values = try decoder.container(keyedBy: CodingKeys.self)
            tabbedSearchResultsRenderer = try values.decodeIfPresent(TabbedSearchResultsRenderer.self, forKey: .tabbedSearchResultsRenderer)
        }
        struct TabbedSearchResultsRenderer: Codable {
            let tabs:[Tab]?
            enum CodingKeys: String, CodingKey {
                case tabs = "tabs"
            }
            init(from decoder: Decoder) throws {
                let values = try decoder.container(keyedBy: CodingKeys.self)
                tabs = try values.decodeIfPresent([Tab].self, forKey: .tabs)
            }
            struct Tab:Codable {
                let tabRenderer:TabRenderer?
                enum CodingKeys: String, CodingKey {
                    case tabRenderer = "tabRenderer"
                }
                init(from decoder: Decoder) throws {
                    let values = try decoder.container(keyedBy: CodingKeys.self)
                    tabRenderer = try values.decodeIfPresent(TabRenderer.self, forKey: .tabRenderer)
                }
                struct TabRenderer: Codable {
                    let content:Content?
                    enum CodingKeys: String, CodingKey {
                        case content = "content"
                    }
                    init(from decoder: Decoder) throws {
                        let values = try decoder.container(keyedBy: CodingKeys.self)
                        content = try values.decodeIfPresent(Content.self, forKey: .content)
                    }
                    struct Content: Codable {
                        let sectionListRenderer:SectionListRenderer?
                        enum CodingKeys: String, CodingKey {
                            case sectionListRenderer = "sectionListRenderer"
                        }
                        init(from decoder: Decoder) throws {
                            let values = try decoder.container(keyedBy: CodingKeys.self)
                            sectionListRenderer = try values.decodeIfPresent(SectionListRenderer.self, forKey: .sectionListRenderer)
                        }
                        struct SectionListRenderer: Codable {
                            ///模块（每个模块内容不一样）
                            let contents:[Content]?
                            enum CodingKeys: String, CodingKey {
                                case contents = "contents"
                            }
                            init(from decoder: Decoder) throws {
                                let values = try decoder.container(keyedBy: CodingKeys.self)
                                contents = try values.decodeIfPresent([Content].self, forKey: .contents)
                            }
                            struct Content:Codable {
                                let musicShelfRenderer:MusicShelfRenderer?
                                enum CodingKeys: String, CodingKey {
                                    case musicShelfRenderer = "musicShelfRenderer"
                                }
                                init(from decoder: Decoder) throws {
                                    let values = try decoder.container(keyedBy: CodingKeys.self)
                                    musicShelfRenderer = try values.decodeIfPresent(MusicShelfRenderer.self, forKey: .musicShelfRenderer)
                                }
                                struct MusicShelfRenderer: Codable {
                                    ///内容块
                                    let contents:[Content]?
                                    ///继续请求块
                                    let continuations:[Continuation]?
                                    enum CodingKeys: String, CodingKey {
                                        case contents = "contents"
                                        case continuations = "continuations"
                                    }
                                    init(from decoder: Decoder) throws {
                                        let values = try decoder.container(keyedBy: CodingKeys.self)
                                        contents = try values.decodeIfPresent([Content].self, forKey: .contents)
                                        continuations = try values.decodeIfPresent([Continuation].self, forKey: .continuations)
                                    }
                                    ///内容块
                                    struct Content: Codable {
                                        let musicResponsiveListItemRenderer:RootMusicResponsiveListItemRenderer?
                                        
                                        enum CodingKeys: String, CodingKey {
                                            case musicResponsiveListItemRenderer = "musicResponsiveListItemRenderer"
                                        }
                                        init(from decoder: Decoder) throws {
                                            let values = try decoder.container(keyedBy: CodingKeys.self)
                                            musicResponsiveListItemRenderer = try values.decodeIfPresent(RootMusicResponsiveListItemRenderer.self, forKey: .musicResponsiveListItemRenderer)
                                        }
                                    }
                                    ///继续请求块
                                    struct Continuation: Codable {
                                        let nextContinuationData:NextContinuationData?
                                        enum CodingKeys: String, CodingKey {
                                            case nextContinuationData = "nextContinuationData"
                                        }
                                        init(from decoder: Decoder) throws {
                                            let values = try decoder.container(keyedBy: CodingKeys.self)
                                            nextContinuationData = try values.decodeIfPresent(NextContinuationData.self, forKey: .nextContinuationData)
                                        }
                                        struct NextContinuationData: Codable {
                                            ///继续请求编码
                                            let continuation:String?
                                            ///继续请求参数
                                            let clickTrackingParams:String?
                                            enum CodingKeys: String, CodingKey {
                                                case continuation = "continuation"
                                                case clickTrackingParams = "clickTrackingParams"
                                            }
                                            init(from decoder: Decoder) throws {
                                                let values = try decoder.container(keyedBy: CodingKeys.self)
                                                continuation = try values.decodeIfPresent(String.self, forKey: .continuation)
                                                clickTrackingParams = try values.decodeIfPresent(String.self, forKey: .clickTrackingParams)
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
