package com.correx.core.talkie.l3

import com.correx.core.events.types.SessionId
import kotlinx.serialization.Serializable

@Serializable
data class L3MemoryEntry(
    val id: String,
    val sessionId: SessionId,
    val turnId: String,
    val text: String,
    val vector: FloatArray,
    val timestampMs: Long
) {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as L3MemoryEntry

        if (id != other.id) return false
        if (sessionId != other.sessionId) return false
        if (turnId != other.turnId) return false
        if (text != other.text) return false
        if (!vector.contentEquals(other.vector)) return false
        if (timestampMs != other.timestampMs) return false

        return true
    }

    override fun hashCode(): Int {
        var result = id.hashCode()
        result = 31 * result + sessionId.hashCode()
        result = 31 * result + turnId.hashCode()
        result = 31 * result + text.hashCode()
        result = 31 * result + vector.contentHashCode()
        result = 31 * result + timestampMs.hashCode()
        return result
    }

    override fun toString(): String {
        return "L3MemoryEntry(id='$id', sessionId='$sessionId', turnId='$turnId', " +
            "text='$text', vector=${vector.contentToString()}, timestampMs=$timestampMs)"
    }
}
