package com.labexposed.notas.ui import com.labexposed.notas.data.local.NoteEntity internal fun filterNotes( notes: List, query: String, categoryId: String? = null, tag: String? = null, ): List { val normalizedQuery = query.trim() return notes.filter { note -> (categoryId == null || note.categories.split(",").contains(categoryId)) && (tag == null || note.tags.split(",").contains(tag)) && (normalizedQuery.isEmpty() || note.title.contains(normalizedQuery, ignoreCase = true) || note.content.contains(normalizedQuery, ignoreCase = true) || note.tags.split(",").any { it.contains(normalizedQuery, ignoreCase = true) }) } }