import SwiftUI

enum Route: Hashable {
    // AI
    case aiChat
    case dailyThinking
    case aiFeedback
    case activeRecall
    case weakPoints
    case reviewCard

    // Library
    case librarySearch
    case libraryDetail(knowledgeBaseId: String)
    case libraryImport
    case libraryCreate
    case addKnowledge(knowledgeBaseId: String)
    case knowledgeDetail(item: KnowledgeItem)
    case editKnowledge(item: KnowledgeItem)

    // Study
    case learningSession(taskTitle: String, taskType: String, taskColorHex: String)
    case studyHome

    // Import
    case importReview(sourceId: String)

    // Quiz
    case quizList(knowledgeBaseId: String)
    case quizTake(quizId: String)
    case quizResult(quizId: String, attemptId: String)

    // Profile
    case notificationList
    case settings
    case goalSetting
    case methodPreference
    case feedbackForm
    case editProfile
}

extension Route {
    @ViewBuilder
    var destination: some View {
        switch self {
        case .aiChat:             AIChatPage()
        case .dailyThinking:      DailyThinkingPage()
        case .aiFeedback:         AIFeedbackPageView()
        case .activeRecall:       ActiveRecallView()
        case .weakPoints:         WeakPointsPage()
        case .reviewCard:         ReviewCardView()

        case .librarySearch:      LibrarySearchView()
        case .libraryDetail(let id): LibraryDetailPage(knowledgeBaseId: id)
        case .libraryImport:      ImportPage()
        case .libraryCreate:      CreateLibraryPage()
        case .addKnowledge(let id): AddKnowledgePage(knowledgeBaseId: id)
        case .knowledgeDetail(let item): KnowledgeDetailPage(item: item)
        case .editKnowledge(let item): EditKnowledgePage(item: item)

        case .learningSession(let title, let type, let colorHex):
            LearningSessionView(taskTitle: title, taskType: type, taskColor: Color(hex: colorHex))
        case .studyHome:          StudyHomeView()

        case .notificationList:   NotificationListView()
        case .settings:           SettingsView()
        case .goalSetting:        GoalSettingDetailView()
        case .methodPreference:   MethodPreferenceView()
        case .feedbackForm:       FeedbackFormView()
        case .editProfile:        EditProfilePage()
        case .importReview(let sourceId): ImportReviewPage(sourceId: sourceId)
        case .quizList(let kbId):        QuizListView(knowledgeBaseId: kbId)
        case .quizTake(let id):          QuizTakerView(quizId: id)
        case .quizResult(let qid, let aid): QuizResultView(quizId: qid, attemptId: aid)
        }
    }
}
