def strip_whitespaces(s: str) -> str: """Strip duplicate whitespaces from a string.""" return " ".join(s.strip().split()) def is_empty(s: str | None) -> bool: """Check if a string is empty.""" return not s or not strip_whitespaces(s)