//
//  AppRouterChat.swift

//
//  Created by Leon on 2025/8/15.
//

import Foundation

extension AppRouter{
    static func goNoticeCenter(){
        guard UserCore.shared.checkUserLoginIfNotPushUserToLogin() else{return}
        
        let vc = NoticeCenterListController()
        UIWindow.getTopNavigationController()?.pushViewController(vc, animated: true)
    }
    
    static func goChatVC(accId: String, complete: (() -> Void)? = nil) {
        guard UserCore.shared.checkUserLoginIfNotPushUserToLogin() else{return}
        
        let vc = SessionController(accountID: accId)
        let nvc = UIWindow.getTopViewController(base: UIWindow.applicationKey?.rootViewController)?.navigationController
        nvc?.pushViewController(vc, animated: true)
        complete?()
    }
    
    static func goChatVC(aiId: Int?, complete: (() -> Void)? = nil) {
        guard UserCore.shared.checkUserLoginIfNotPushUserToLogin() else{return}
        
        guard let aiUserId = aiId,  let accId = IMUserKit.accountIdWithAIId(aiId: aiUserId) else{return}
        
        let vc = SessionController(accountID: accId)
        let nvc = UIWindow.getTopViewController(base: UIWindow.applicationKey?.rootViewController)?.navigationController
        nvc?.pushViewController(vc, animated: true)
        complete?()
    }
    
    static func goChatVC(conversationId: String?, title: String? = nil, complete: (() -> Void)? = nil) {
        guard UserCore.shared.checkUserLoginIfNotPushUserToLogin() else{return}
        
        guard let sessionId  = conversationId else{return}
        let vc = SessionController(conversationId: sessionId, title: title)
        let nvc = UIWindow.getTopViewController(base: UIWindow.applicationKey?.rootViewController)?.navigationController
        nvc?.pushViewController(vc, animated: true)
        complete?()
    }
}
