package com.dano.test1.questionnaire

data class Option(
    val key: String,               // Must always be set
    val nextQuestionId: String? = null
)

data class ValueOption(
    val value: Int,
    val nextQuestionId: String? = null
)

data class Range(
    val min: Int,
    val max: Int
)

data class Constraints(
    val notBefore: String? = null,
    val notAfter: String? = null
)

sealed class QuestionItem {
    abstract val layout: String?
    abstract val id: String

    data class ClientCoachCodeQuestion(
        override val layout: String?,
        override val id: String,
        val question: String,
        val hint1: String?,
        val hint2: String?
    ) : QuestionItem()

    data class RadioQuestion(
        override val layout: String?,
        override val id: String,
        val textKey: String?,
        val question: String?,
        val options: List<Option>,
        val pointsMap: Map<String, Int>? = null
    ) : QuestionItem()

    data class GlassScaleQuestion(
        override val layout: String?,
        override val id: String,
        val textKey: String?,
        val question: String,
        val symptomTextKeys: List<String>,
        val pointsMap: Map<String, Int>,
        val symptoms: List<String>
    ) : QuestionItem()

    data class ClientNotSigned(
        override val layout: String?,
        override val id: String,
        val textKey1: String?,
        val textKey2: String?,
        val question: String,
        val hint: String?
    ) : QuestionItem()

    data class MultiCheckboxQuestion(
        override val id: String,
        override val layout: String,
        val textKey: String?,
        val question: String,
        val options: List<Option>,
        val nextQuestionId: String?,
        val pointsMap: Map<String, Int>?,
        val minSelection: Int = 1
    ) : QuestionItem()

    data class DateSpinnerQuestion(
        override val layout: String?,
        override val id: String,
        val textKey: String?,
        val question: String,
        val nextQuestionId: String? = null,
        val storeAsGlobalKey: String? = null,
        val constraints: Constraints? = null
    ) : QuestionItem()

    data class ValueSpinnerQuestion(
        override val layout: String?,
        override val id: String,
        val textKey: String?,
        val question: String,
        val options: List<ValueOption> = emptyList(),
        val range: Range? = null
    ) : QuestionItem()

    data class StringSpinnerQuestion(
        override val layout: String?,
        override val id: String,
        val textKey: String?,
        val question: String,
        val options: List<String>,
        val nextQuestionId: String? = null
    ) : QuestionItem()

    data class LastPage(
        override val layout: String?,
        override val id: String,
        val textKey: String,
        val question: String
    ) : QuestionItem()

    data class QuestionnaireEntry(
        val file: String,
        val condition: Condition? = null,
        val showPoints: Boolean = false  // neu
    )

    // flexible Condition-Typen für die questionnaire_order.json
    sealed class Condition {
        object AlwaysAvailable : Condition()
        data class RequiresCompleted(val required: List<String>) : Condition()
        data class QuestionCondition(
            val questionnaire: String,
            val questionId: String,
            val operator: String,
            val value: String
        ) : Condition()

        data class Combined(
            val requiresCompleted: List<String>?,
            val questionCheck: QuestionCondition?
        ) : Condition()

        data class AnyOf(val conditions: List<Condition>) : Condition()
    }
}
